【发布时间】:2015-08-06 14:45:26
【问题描述】:
关于这个其他主题:.htaccess redirect according to PHP parameters 我得到了根据一些 PHP 参数进行重定向的帮助,例如,像
/forum/viewtopic.php?t=123 redirected to /page1.html
/forum/viewtopic.php?t=345 redirected to /page7.html
/forum/viewtopic.php?t=89 redirected to page3.html
建议的(工作)解决方案是
RewriteEngine On
RewriteCond %{QUERY_STRING} ^t=123$
RewriteRule ^forum/viewtopic\.php$ /page1.html? [L,R=301]
RewriteCond %{QUERY_STRING} ^t=345$
RewriteRule ^forum/viewtopic\.php$ /page7.html? [L,R=301]
RewriteCond %{QUERY_STRING} ^t=89$
RewriteRule ^forum/viewtopic\.php$ /page3.html? [L,R=301]
我想在最后添加一个“一般”案例:如果没有匹配的 URL,并且询问文件夹“/forum”,则重定向到根目录。比如
/forum redirected to /
/forum/viewtopic.php?t=34598237 redirected to /
/forum/something redirected to /
我该怎么做?
【问题讨论】:
标签: php apache .htaccess redirect