我想使用%{QUERY_STRING}进行Apache重定向,但它根本无法正常工作。
我想重定向任何网页中包含字符串的网页查询。 例如:
http://www.domain.com/328kadf83/dkad83kd/test83283/
该字符串将是“test”,如上所示。
我尝试过这个,但它似乎没有起作用:
RewriteEngine On RewriteCond %{QUERY_STRING} test RewriteRule (.*) http://www.other_domain.com/page.html [R=301,L]在这种情况下我做错了什么? 主要的是 - 重定向需要匹配字符串“test”出现的URL中的任何位置 - 然后它将重定向到特定的网页。
我在这里看到的其他问题专门用于目录或页面名称后带变量的目录。
谢谢!
I'm looking to do an Apache redirect using %{QUERY_STRING} but it simply isn't working.
I am wanting to redirect any web page query that has a string anywhere in the URL. So for example:
http://www.domain.com/328kadf83/dkad83kd/test83283/
The string would be "test" as shown above.
I tried this, but it doesn't seem to be working:
RewriteEngine On RewriteCond %{QUERY_STRING} test RewriteRule (.*) http://www.other_domain.com/page.html [R=301,L]What I am doing wrong in this case? The main thing is - the redirect needs to match anywhere in the URL where the string "test" appears - and it will then redirect to a specific web page.
The other questions I've seen on here are specifically for a directory or those with variables after a page name.
Thank you!
最满意答案
应该是这样的:
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} /test [NC] RewriteRule .* http://www.other_domain.com/page.html [R=301,L]Should be something like this:
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} /test [NC] RewriteRule .* http://www.other_domain.com/page.html [R=301,L]更多推荐
发布评论