Hello, I have wildcard DNS enabled at my host so that any subdomain points to my main domain directory. I want to make a script that shows the appropriate content for the requested subdomain but the problem is: How can I find out (using PHP) what subdomain was requested by the user and so show the right content corresponding to the requested subdomain?
Use $_SERVER['HTTP_HOST'] and remove your actual domain from it. Or if there are not dots in the subdomain, you can do: $subdomain = current(explode('.', $_SERVER['HTTP_HOST'])); PHP: