Hello
I am not sure if this question should be posted here, but since I am writing my application in PHP and I am sure someone here will know the answer, I will try. (in the worst case, please move this post somewhere else)
My application needs to perform certain actions if a subdomain was used in accessing the server.
For example, the URL http://dummy1.test.com should trigger a different behaviour than the URL http://www.test.com or http://test.com
Is there a way to obtain the subdomain part in the host without parsing it manually from the $_SERVER['HTTP_HOST'] value?
Also, can it be tested locally?
Usually when I debug my application I surf using http://localhost/
Is there a way to simulate a subdomain on the local machine?
regards
[SOLVED] subdomains in PHP
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
for finding what domain the script is being accessed under: $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME']
As for creating subdomains for testing; depending on your OS, there's virtual hosts and the hosts file. On my machine, changing the hosts file alone, caused both values to switch to the "new" name.
The hosts files is located at:
%WINDIR%\system32\drivers\etc\hosts
As for creating subdomains for testing; depending on your OS, there's virtual hosts and the hosts file. On my machine, changing the hosts file alone, caused both values to switch to the "new" name.
The hosts files is located at:
%WINDIR%\system32\drivers\etc\hosts