我想将访问我的旧phpbb论坛网址的访问者重定向到我的新网址结构
http://mydomain.com/phpbb/viewtopic.php?f=$var1&t=$var2
(f = $ var1,t = $ var2是整数)
到
http://mydomain.com/topic/$var2
我的.htaccess mod_rewrite代码:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^phpbb/viewtopic\.php\?f=\d+&t=(\d+)$ topic/$2 [L]
</IfModule>
但它不起作用。如何更改它的代码?
答案 0 :(得分:1)
将以下内容添加到您网站根文件夹中的.htaccess。
RewriteEngine on
RewriteBase /
#place these two lines before any other rules in your .htacess
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
RewriteRule ^phpbb/viewtopic\.php$ /topic/%2? [L,R,NC]
答案 1 :(得分:0)
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} \bt=([0-9]+)
RewriteRule ^phpbb/viewtopic\.php topic/%1? [R=301,NC,L]