[英]Htaccess 301 redirect one url to another with special characters doesnt work
I need to 301 redirect one URL to another. 我需要301将一个URL重定向到另一个。 Now I have this rule in
.htaccess
现在我在
.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]
But it doesnt work at all. 但它根本不起作用。 Could please anybody help me with that?
有人可以帮我吗?
Thank you very much in advance! 提前非常感谢您!
You cant match query string using RewriteRule
. 您无法使用
RewriteRule
匹配查询字符串。 Use it like this: 像这样使用它:
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]
?
in the end is used to strip-off any existing query string. 最后用于剥离任何现有查询字符串。
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]
just reverse the order and it should work! 只需颠倒顺序,它应该可以工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.