2017-06-19 120 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