2014-12-01 58 views
1

我有以下幾行寫入多次,以適應我們使用的多個域。有沒有辦法寫一次,所以任何域都遵循相同的規則?htaccess重寫任何域

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] 
RewriteCond %{THE_REQUEST} \s/+example.com/(\S*) [NC] 
RewriteRule^/%1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_URI} !^/example.com/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /example.com/$1 [L] 

RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(/)?$ example.com/index.php [L] 

回答

1

嘗試規則的這個單塊全部doamins:

RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] 
RewriteCond %1::%{THE_REQUEST} ^(.+?)::\s/+\1/(\S*) 
RewriteRule^/%1 [R=301,L] 

RewriteCond %{HTTP_HOST}::%{REQUEST_URI} ^(?:www\.)?(.+?)::/(?!\1/) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ %1/$1 [L] 

RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] 
RewriteRule ^/?$ %1/index.php [L]