使用查询重定向不起作用 - htaccess



当我尝试使用URL的普通文本进行重定向时,它工作正常...

Redirect 301 /thisisatest/ http://www.mydomain.com/test-result/

但是当我尝试使用这样的 url 时它不起作用,我已经将问题精确到查询?...

Redirect 301 /sub.php?page=1&panel=1/ http://www.mydomain.com/test-result/

有什么我应该包括的东西吗?

这是因为您无法在Redirect指令中匹配QUEY_STRING。您需要在DOCUMENT_ROOT/.htaccess文件中使用这样的规则mod_rewrite

RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=1&panel=1$ [NC]
RewriteRule ^sub.php$ http://www.mydomain.com/test-result/? [L,R=301,NC]

最新更新