2013-11-15 195 views
1

所以,我有一些問題,我的htacces文件試圖做一些重寫條件。 我想要做的是:Apache htaccess mod重寫

有多個域指向此web文件夾。 如果域名是什麼,但example.com我希望它重寫example.com 除非 - 路徑是/路徑

惟獨當你去www.otherexample.com/path

現在工作

這是擊中最後一條規則,並將網址更改爲http://dev.otherexample.com/index.php?qs-rewrite=path並導致重定向循環。

這裏就是整個htaccess文件

DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
RewriteEngine On 
#RewriteBase/

RewriteCond %{HTTP_HOST}   !example\.com$ [NC] 
RewriteCond %{REQUEST_URI}  !^/path [NC] 
RewriteRule ^.*$     http://dev.example.com%{REQUEST_URI} [L,R=301] 

RewriteCond %{REQUEST_URI}  ^(.*)//(.*)$ 
RewriteRule .      %1/%2 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$     index.php?qs-rewrite=$0&%{QUERY_STRING} [L] 
</IfModule> 

回答

0

這應該是你的完整的.htaccess:

DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{HTTP_HOST}   !example\.com$ [NC] 
RewriteCond %{REQUEST_URI}  !^/path [NC] 
RewriteCond %{QUERY_STRING}  !qs-rewrite=[^&]+ [NC] 
RewriteRule^     http://dev.example.com%{REQUEST_URI} [L,R=301,NE] 

RewriteCond %{REQUEST_URI}  ^(.*)//(.*)$ 
RewriteRule .      /%1/%2 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^     /index.php?qs-rewrite=%{REQUEST_URI} [L,QSA] 
</IfModule> 
+0

我想,和同樣的事情,我加入了整個htaccess的的問題。 –

+0

您使用什麼URL測試此規則? – anubhava

+0

你現在可以嘗試編輯答案嗎? – anubhava