我需要301重定向一个网址到另一个。现在我在.htaccess中有了这个规则
RewriteRule /forum/viewtopic.php?f=65&t=6 /page/name-of-the-page [R=301]
RewriteRule /forum/viewtopic.php?f=30&t=5 /page/another-name-of-the-page [R=301]
但是它根本不起作用。有人能帮我吗?
非常感谢您提前!
发布于 2014-02-21 17:14:51
您不能使用RewriteRule匹配查询字符串。像这样使用它:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^f=65&t=6$
RewriteRule ^forum/viewtopic\.php$ /page/name-of-the-page? [R=301,L]
RewriteCond %{QUERY_STRING} ^f=30&t=5$
RewriteRule ^forum/viewtopic\.php$ /page/another-name-of-the-page? [R=301,L]最后,?用于删除任何现有的查询字符串.
发布于 2014-02-21 17:20:54
RewriteRule /forum/viewtopic.php?f=30&t=5 /page/another-name-of-the-page [R=301]
RewriteRule /forum/viewtopic.php?f=65&t=6 /page/name-of-the-page [R=301]只要倒序,它就能工作了!
https://stackoverflow.com/questions/21940674
复制相似问题