问题描述
如何更改http:mydomainname.com/inner-page.php条款ArticleID = 10到http:??mydomainname.com/inner-page.php条款ArticleID =标题
请给我一个简单的方法我也尝试URL重写。
how to change http:mydomainname.com/inner-page.php?articleid=10 To http:mydomainname.com/inner-page.php?articleid=Title
please give me a easy way i have also tried Apache mod_rewrite.
但我的困惑是,如何.htaccess文件知道我的称号ID
but my confusion is that how to .htaccess file know my title by id
推荐答案
您不能用的mod_rewrite或Apache独自做到这一点,因为没有办法Apache或mod_rewrite的知道如何从10翻译
到标题
。你很可能需要与数据库进行查找做到这一点,你最好在你的这样内page.php
。
You cannot do this with mod_rewrite or Apache alone, because there is no way Apache or mod_rewrite know how to translate from "10"
to "Title"
. You'll most likely want to do this with a database lookup, and you are better off doing this in your inner-page.php
.
if( isset( $_GET['articleid'] ) ) {
$title = database_lookup_function( $_GET['articleid'] );
header( '302 Moved Temporarily' );
header( "location: /inner-page.php?articletitle=$title" );
exit();
}
或者,如果你真的想保持相同的变量彻底你的整个脚本,这听起来很傻:
Or if you really want to keep the same variable thorough your entire script, which sounds silly:
if( isset( $_GET['articleid'] ) && intval( $_GET['articleid'], 10 ) == $_GET['articleid'] ) {
$title = database_lookup_function( $_GET['articleid'] );
header( '302 Moved Temporarily' );
header( "location: /inner-page.php?articleid=$title" );
exit();
}
要加载<$c$c>inner-page.php?category=radiono&lanug=India&articleid=sarukh-khan-performs-a-natural-language$c$c>当内page.php / radiono /印度/ sarukh汗 - 执行 - 一个自然语言
要求,使用以下规则:
To load inner-page.php?category=radiono&lanug=India&articleid=sarukh-khan-performs-a-natural-language
when inner-page.php/radiono/India/sarukh-khan-performs-a-natural-language
is requested, use the following rule:
RewriteRule ^inner-page\.php/([^/]+)/([^/]+)/([^/]+)/?$ /inner-page.php?category=$1&lanug=$2&articleid=$3 [L]
这篇关于如何更改http:mydomainname.com/inner-page.php条款ArticleID = 10到http:mydomainname.com/inner-page.php/Title的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!