2014-12-05 18 views
1

@anubhava的幫助,我有這個漂亮的RewriteRule工作。如何讓RewriteRule子域不可知?

short.dev redirects to longer.dev 
short.com redirects to longer.com 

使用此:

RewriteCond %{HTTP_HOST} ^(?:www\.)?short\.(.+)$ [NC] 
RewriteRule^http://longer.%1%{REQUEST_URI} [R=301,L] 

我現在需要擴展此規則,以使其子域不可知也 - 樣:

www.short.dev redirects to www.longer.dev 
www.short.com redirects to www.longer.com 

es.short.dev redirects to es.longer.dev 
es.short.com redirects to es.longer.com 

回答

1

你可以讓第一組爲拍攝組

RewriteCond %{HTTP_HOST} ^(www\.)?short\.(.+)$ [NC] 
RewriteRule^http://%1longer.%2%{REQUEST_URI} [R=301,L,NE] 
:在後臺備日後參考使用