homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Virtual Hosts and PHP

 8:06 am on Apr 11, 2010 (gmt 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)

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


[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)

Unfortunately the target got parsed as a URL...


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved