2013-11-15 132 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