简体   繁体   中英

How to handle and identify multiple sub-domains

I am planning for multiple sub-domain names based on city, something like city1.mydomain.com, city2.mydomain.com, ... All sub-domains will point to same file structure on main domain. Then in my program I would like to capture the city name and display content based on city.

What is the best approach to identify the city (based on the sub-domain selected). - By reading the host name? - or by htaccess mod-rewrite? - or something else?

Thanks!

city1 is no sub-domain but a hostname of mydomain.com.

but nevermind. you have one vhost with all city* as alias of this host. so each request to one of the hostnames will be served by the same script.

in the script you determine the hostname and display your content accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM