2010-06-30 95 views
1

我很好奇,有没有更有效的方法来做到以下几点?现在,它的伟大工程,只是似乎有点小题大做......重写逻辑,有没有更好的方法来做到这一点?

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteCond %{HTTP_HOST} !^www\.clientcollabhq\.com$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.clientcollabhq\.com$ [NC] 
RewriteRule ^(.+)$ /index.php?subdomain=%2&kohana_uri=$1 [PT,L,QSA] 

RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf)$ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(.+)$ /index.php?kohana_uri=$1 [PT,L,QSA] 

问候, 安德鲁

回答

2

您可以使用常见的情况在倒置形式条件中断/跳过规则:

# stop processing if one of these conditions are fulfilled 
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf)$ [OR] 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -l 
RewriteRule^- [L] 

RewriteCond %{HTTP_HOST} !^www\.clientcollabhq\.com$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.clientcollabhq\.com$ [NC] 
RewriteRule ^(.+)$ /index.php?subdomain=%2&kohana_uri=$1 [PT,L,QSA] 

RewriteRule ^(.+)$ /index.php?kohana_uri=$1 [PT,L,QSA] 

现在,每个匹配这些条件之一的请求将使该规则适用,从而结束重写过程。

+0

这工作完美!谢谢! – 2010-07-08 18:49:49

相关问题