2017-06-19 122 views
0

这是我的页面 http://example.com/index.html。 我想使它像这样工作。Apache重定向和重写

响应我已经尝试

RewriteCond %{QUERY_STRING} ^$ 
    RewriteRule ^/index.html$ http://def.com 

回答

1

更改您的htaccess文件这样的:

RewriteCond %{QUERY_STRING} ^(headers=0|)$ [NC] 
RewriteRule ^index.html$ http://def.com [R=301,L] 
+0

谢谢@ sreedev-sb – akimran82

+0

嗨,现在,如果我需要匹配任何不包含查询字符串头的东西呢?我试过RewriteCond%{QUERY_STRING} ^(!头文件)$ [NC] RewriteRule^index.html $ http://def.com [R = 301,L]但这不起作用。 – akimran82

+0

@ akimran82 RewriteCond%{QUERY_STRING}!^标题 –

1

更改您的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