我在设置以下301重定向时遇到问题。
我正在尝试重定向:
https://www.example.com/blog/wp-includes/js/jquery/jquery.js?ver=1.11.3
转到主页:
https://www.example.com/
这是我试过的,但没有用。
Redirect 301 "/blog/wp-includes/js/jquery/jquery.js'?ver'=1'.11'.3" "/"
如本页所述https://simonecarletti.com/blog/2009/01/apache-query-string-redirects/
遗憾的是,
Redirect
和RedirectMatch
都不允许为重定向源指定查询字符串。
因此,您必须切换到使用mod_rewrite
,即使用以下内容:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/blog/wp-includes/js/jquery/jquery'.js$
RewriteCond %{QUERY_STRING} ^ver=1'.11'.3$
RewriteRule ^(.*)$ / [R=301,L]
QueryString不是Redirect指令中匹配的一部分,您需要使用mod rewrite与%{THE_REQUEST}匹配,请尝试:
RewriteEngine on
RewriteCond %{THE_REQUEST} /blog/wp-includes/js/jquery/jquery'.js'?ver=1'.11'.3 [NC]
RewriteRule ^ /? [L,R]
您可以删除如果您想将查询字符串转发到主页,请从目标路径。