.htaccess redirect foo.com/ to /foo.htm, leave bar.com/ as bar.com
Note: I had to add spaces because it thought I was posting links...
I have two sites coming into one server and one folder (foo.com
and bar.com
).
Foo.com
needs to point at a page named foo.htm
under the root of the site.
It also has the requirement of not changing the URL.
If the url is bar.com
it needs to be left alone.
If the full url is http://www.foo.com/
it needs to be switched to the equivalent of
http://bar.com/foo.htm
开发者_如何学JAVADoes that make sense?
I have the following which works for every page except the root page, which isn't redirecting to foo.htm
.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo\.com
RewriteRule ^(.*)$ http://www.bar.com/$1
RewriteRule ^$ /foo.htm [L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo\.com
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule ^$ http://www.bar.com/foo.htm [L]
RewriteCond %{HTTP_HOST} ^foo\.com
RewriteCond %{REQUEST_URI} ^/.
RewriteRule ^(.*)$ http://www.bar.com/$1
I'm not sure if it will run exactly like this as I can't test it - but if it doesn't work, just modify the regex in RewriteCond %{REQUEST_URI} .... possibly remove the slash and question mark... just try it.
精彩评论