开发者

.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
开发者_如何学JAVA

Does 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜