繁体   English   中英

htaccess 301使用特殊字符将一个URL重定向到另一个URL不起作用

[英]Htaccess 301 redirect one url to another with special characters doesnt work

我需要301将一个URL重定向到另一个。 现在我在.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]

但它根本不起作用。 有人可以帮我吗?

提前非常感谢您!

您无法使用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]

? 最后用于剥离任何现有查询字符串。

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]

只需颠倒顺序,它应该可以工作!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM