On my website i’m using virtual host so my users can have virtual domain like ‘user1.mydomain.com’, ‘user2.mydomain.com’,…
The problem is that on virtual domains like ‘user1.domain.com’ the index page is always the same as on my index page ‘http://mydomain.com’.
What i want to do is to have two different index pages for the domain and for subdomains. My question, how to have subdomains redirected to ‘index2.php’ (for example) and still have the subdomains to look like ‘user1.mydomain.com’?
Ideally, you would set up completely separate document directories for each subdomain.
vhostin apache is the way to go. If you however want to do it your way (subdomains redirecting to individual files), then it’s a bit more work, but is still doable. First, define themod_vhostwith wildcard:Then inside this
VirtualHostsetup rewrite rules usingmod_rewrite:Note however that this will only work properly for
/and/index.phprequests to subdomains. You are much better off setting up separate document root directories for each subdomain if you intend to do anything more than this.