Welcome to WebmasterWorld Guest from 54.146.221.231

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Virtual Hosts and PHP

     
8:06 am on Apr 11, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 20, 2008
posts: 172
votes: 0


Hi, so I have setup a site which uses virtual hosts. The site starts with login.example.com, and redirects if successful into anotherplace.example.com.

Trouble is, is that I want the browser to detect if I enter http://www.example.com/login , where the vhost root directory is, and either generate a 404, or have it redirect to login.example.com, but am not sure how.

So I am wondering what the best way to do this is, considering my include files point to the virtual hosts' root i.e. http://example.com/login/includes, and not the actual root. Is .htaccess the recommended option, or something else?
12:01 pm on Apr 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:943
votes: 0


.htaccess should work.

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^login/?$ http://login.example.com [R=301,L]

However, I do advise getting the above checked in the Apache forums here on Webmaster World.

[webmasterworld.com...]

[edited by: eelixduppy at 1:42 am (utc) on Apr 12, 2010]
[edit reason] formatting [/edit]

1:59 pm on Apr 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:943
votes: 0


Unfortunately the target got parsed as a URL...

http://
login.example.com