I am working on classified site. I am using PHP and MySql for that.
On my site when user select their city that time i want to change website url like in subdomain style. foreg:-
http://cityname.mywebsitename.com
Only one thing in my mind to implement this is creating sub domains for all cities. But it would be more difficult to manage when your cities goes 50+. You can’t upload again and again same script for multiple domains. I think this is not a good idea to do this. I want to use a single script for that so i can manage it in simple way.
If you have any idea than please share..
Thanks in advance
I say you how i made it:
in DNS add wildcard subdomain record
*.domain.tld. IN A 1.2.3.4
add wildcard virtualhost
create a .htaccess that redirect all requests to a FrontController (usually index.php)
parse
$_SERVER['HTTP_HOST']from php to obtain city name and play with your new FrontController (usually index.php)i’ve done it on dedicated server or VPS with linux and plesk. With some modifications on the previous basis points, it is possible everywhere;)