Apache重定向和重写
问题描述:
这是我的页面 http://example.com/index.html。 我想使它像这样工作。Apache重定向和重写
- 我想,当他要求 http://example.com/index.html
- 即使他要求http://example.com/index.html?headers=0,他应采取 到http://def.com
- 但采取用户http://def.com如果他请求同样的URL与其他查询参数例如http://example.com/index.html?footer=1,那么重定向或重写就不应该发生。他仍然应该看到从http://example.com/index.html?footer=1
响应我已经尝试
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/index.html$ http://def.com
答
更改您的htaccess文件这样的:
RewriteCond %{QUERY_STRING} ^(headers=0|)$ [NC]
RewriteRule ^index.html$ http://def.com [R=301,L]
答
更改您的htaccess文件这样的:
RewriteCond %{QUERY_STRING} ^$ [OR]
RewriteCond %{QUERY_STRING} !headers
RewriteRule ^index.html$ http://def.com [R=301,L]
+0
下面的命令实际上对我很有用\t RewriteCond%{QUERY_STRING}!headers RewriteRule^index.html $ http://def.com [R = 301,L] – akimran82
谢谢@ sreedev-sb – akimran82
嗨,现在,如果我需要匹配任何不包含查询字符串头的东西呢?我试过RewriteCond%{QUERY_STRING} ^(!头文件)$ [NC] RewriteRule^index.html $ http://def.com [R = 301,L]但这不起作用。 – akimran82
@ akimran82 RewriteCond%{QUERY_STRING}!^标题 –