我想做以下重定向:
http://example.com to some static page
http://exmaple.com/<anything> to http://subdomain.example.com/<anything>
目前我有这个:
RewriteRule ^/?$ static/index.html [L]
RewriteRule ^(*)?$ http://sub.example.com/$1 [L]
感谢任何帮助。 感谢
答案 0 :(得分:1)
您可以尝试以下规则:
RewriteEngine on
#1)This will redirect the homepage of example.com to /static/index.html#
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^$ /static/index.html [NC,L]
#2)This will redirect /anything to sub.example.com#
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{REQUEST_URI} !^/static/index\.html [NC]
RewriteRule ^(.+)$ http://sub.example.com/$1 [NC,L,R,NE]