合并htaccess HTTP_HOST重写Cond

时间:2013-04-03 13:41:32

标签: apache .htaccess

我有这个htaccess条件......

# 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?因为所有人都这样做。

谢谢,来自西班牙的问候。

1 个答案:

答案 0 :(得分:1)

尝试:

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