Mobile app version of vmapp.org
Login or Join
Harper822

: Make all subdomains load the same page, how is it called/done? Is there a way to make all subdomains show the same page. I got the idea somewhere you could have a page like idk information.com

@Harper822

Posted in: #Html #Php #Subdomain

Is there a way to make all subdomains show the same page.

I got the idea somewhere you could have a page like idk information.com and if an user typed miami.information.com he would get information from that city.

Is there a way to do it?

Like making the site retrieve the first part of the subdomain and search it on the site.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Harper822

1 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

The final configuration depends on the web server you'll be using but in Apache httpd you'd simply create a wildcard virtual host:

<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
# other configuration directives
</VirtualHost>


Prerequisite is that there's a *.example.com A (or CNAME) resource record in your zone for example.com. Ask your name server administrator about it.

In your PHP scripts you can then simply evaluate $_SERVER['HTTP_HOST'] to get the first component of the hostname.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme