我已尝试过以下
RewriteEngine On
RewriteCond %{QUERY_STRING} ^slides=(.*)$
RewriteRule ^/([a-zA-Z\-0-9_]+)/.*$ /$1/ [R=301,L]
对于URLS来说
http://example.com/whatever-in-here/?slides=asdf
被重定向到http://example.com/whatever-in-here/?
然而它不起作用
答案 0 :(得分:0)
答案 1 :(得分:0)
要剥离查询字符串,您可以在目标中添加?
:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^slides=(.*)$
RewriteRule ^ %{REQUEST_URI}? [NE,R=301,L]
另请注意,您不需要在RewriteRule
中对URI进行分组和捕获,因为您可以使用%{REQUEST_URI}
。