Welcome to WebmasterWorld Guest from 54.147.147.191

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Virtual Hosts and PHP

     

username

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

5+ Year Member



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?

Readie

12:01 pm on Apr 11, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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

Readie

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

WebmasterWorld Senior Member 5+ Year Member



Unfortunately the target got parsed as a URL...

http://
login.example.com
 

Featured Threads

Hot Threads This Week

Hot Threads This Month