2013-04-03 28 views
1

我有這個條件htaccess的...合併htaccess的HTTP_HOST改寫電導率

# changed... subdomains to subdirectories... 
RewriteCond %{HTTP_HOST} ^acoruna.domain\.es [nc] 
RewriteRule (.*) http://domain.es/acoruna/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^alava.domain\.es [nc] 
RewriteRule (.*) http://domain.es/alava/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^albacete.domain\.es [nc] 
RewriteRule (.*) http://domain.es/albacete/$1 [R=301,L] 
# changed... subdomains to subdirectories... 

我的問題是,,我可以合併所有的RewriteCond &重寫規則,只有1?因爲所有人都這樣做。

謝謝,來自西班牙的問候。

+0

您可以捕獲子域部分與正則表達式的RewriteCond,然後引用,在你的重寫規則,是的。 – CBroe

回答

1

嘗試:

RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.es$ [NC] 
RewriteRule ^(.*)$ http://domain.es/%1/$1 [R=301,L]