我正在尝试执行以下重定向:
如果用户来自:www.example.com/folder/sub-folder/
,则会重定向到www.example.com/filehtml.html
这是正常的。
如果用户来自:www.example.com/folder/sub-folder/index.html
,则会将其重定向到www.example.com/filehtml.html
这不起作用。
如果用户来自:www.example.com/folder/sub-folder/?id=1&id2=2
,则会将其重定向到www.example.com/filehtml.html?id=1&id2=2
这是正常的。
如果用户来自:www.example.com/folder/sub-folder/index.html?id=1&id2=2
,则会将其重定向到www.example.com/filehtml.html?id=1&id2=2
这不起作用。
Redirect 301 /folder/sub-folder/ /filehtml.html
RewriteCond %{HTTP_HOST} ^www\.site\.pt$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^folder/sub-folder/index\.html$ http://www.example.com/filehtml.html%{REQUEST_URI} [R=301,NC]
我做错了什么?
答案 0 :(得分:0)
使用此规则替换所有代码:
RewriteEngine On
RewriteRule ^folder/sub-folder/ /filehtml.html [L,NC,R=302]
QUERY_STRING会自动转移到/filehtml.html
。