redirect - Subdomain hosting on Apache -
i beginner in web server related stuff.
i have server working domain www.example.com
i want host test.example.com
on server have same behavior www.example.com
. is, requests test.example.com should mapped start.php file.
also domain name should remain test.example.com
, i.e. don't want redirect requests test.example.com
www.example.com
.
how achieve this?
your solution name-based virtual host.
specifically, want set virtual host direct requests specific host (in case, identified subdomain) particular directory. thereafter, rewrite requests start.php
.
<virtualhost *> servername mysub.domain.tld documentroot /www/vhosts/http/mysub.domain.tld rewriteengine on rewriterule ^(.*)$ start.php [l] </virtualhost>
place in apache configuration file or separate file in sites-available
directory, enabling via a2ensite
. make sure 1 loaded before 1 domain.tld
, or else apache recognize path domain.tld
, forget mysub.domain.tld
.
restart apache, , should go.
Comments
Post a Comment