我有这个 .htaccess 行:
RewriteRule ^forum_(.*).html forum.php?frm=$1 [L]
我有这个 php 行:
$url = str_ireplace('forum.php?frm=', 'forum_.html', $url);
但是网址变成了这样:
forum_.html1
我希望网址变成这样:
forum_1.html
怎么做??
完整的 .htaccess 文件:
RewriteEngine On
# begin index Page Rewriting
RewriteRule ^index index.php [L]
RewriteRule ^index.html index.php [L]
RewriteRule ^index.htm index.php [L]
RewriteRule ^forum_(.*)\.html forum.php?frm=$1 [L]
RewriteRule ^topics_(.*) thread.php?tpc=$1 [L]
RewriteRule ^tpcs_auth_(.*) tpcs.php?auth=$1 [L]
RewriteRule ^tpcs_rauth_(.*) tpcs.php?rauth=$1 [L]
RewriteRule ^users_(.*) user.php?id=$1 [L]
RewriteRule ^chat.html chat.php [L]
RewriteRule ^signup.html signup.php [L]
RewriteRule ^users.html users.php [L]
RewriteRule ^cp.html Upanel.php [L]
RewriteRule ^messages.html pm.php [L]
RewriteRule ^style=(.*) changetemplate.php?action=changestl&styleid=$1 [L]
RewriteRule ^lostpw.html lostpw.php [L]
# end
完整的 seo.php 文件:
$seotp = $config->Cquery("site_seo");
if($seotp == 0)ob_start();
function change_links(){
global $seotp;
if($seotp == 0){
$contents = ob_get_contents();
$contents = rewrite($contents);
ob_end_clean();
echo $contents;
}
}
function rewrite($url){
global $seotp;
if($seotp == 0){
$url = str_ireplace('href="index.php', 'href="index.html', $url);
$url = str_ireplace('href="./index.php', 'href="./index.html', $url);
$url = str_ireplace('href="./forum.php?frm=', 'href="./forum_.html', $url);
$url = str_ireplace('forum.php?frm=', 'forum_.html', $url);
$url = str_ireplace('href="./thread.php?tpc=', 'href="./topics_', $url);
$url = str_ireplace('thread.php?tpc=', 'topics_', $url);
$url = str_ireplace('href="./user.php?id=', 'href="./users_', $url);
$url = str_ireplace('user.php?id=', 'users_', $url);
$url = str_ireplace('tpcs.php?auth=', 'tpcs_auth_', $url);
$url = str_ireplace('tpcs.php?rauth=', 'tpcs_rauth_', $url);
$url = str_ireplace('href="./tpcs.php?auth=', 'href="./tpcs_auth_', $url);
$url = str_ireplace('href="./tpcs.php?rauth=', 'href="./tpcs_rauth_', $url);
$url = str_ireplace('href="chat.php', 'href="chat.html', $url);
$url = str_ireplace('href="users.php', 'href="users.html', $url);
$url = str_ireplace('href="./users.php', 'href="./users.html', $url);
$url = str_ireplace('href="singup.php', 'href=".singup.html', $url);
$url = str_ireplace('href="./singup.php', 'href="./singup.html', $url);
$url = str_ireplace('href="./Upanel.php', 'href="./cp.html', $url);
$url = str_ireplace('href="Upanel.php', 'href="cp.html', $url);
$url = str_ireplace('href="./pm.php', 'href="./messages.html', $url);
$url = str_ireplace('href="pm.php', 'href="messages.html', $url);
$url = str_ireplace('href="./lostpw.php', 'href="./lostpw.html', $url);
$url = str_ireplace('href="lostpw.php', 'href="lostpw.html', $url);
$url = str_ireplace('href="./changetemplate.php?action=changestl&styleid=', 'href="./style=', $url);
$url = str_ireplace('href="changetemplate.php?action=changestl&styleid=', 'href="style=', $url);
return $url;
}
}
调用函数时:change_links();