.htaccess - subdomains linked to different files using htaccess -
i'm trying create redirect different files different subdomains, maybe domains in future. based on modx cms.
i want keep url same, run different file each subdomain, passing data. domain.com it's index.php, sub1.domain.com - sub1.php. want pass data, can see in example below:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^www\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /index.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub1\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub1.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub2\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub2.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub3\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub3.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub4\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub4.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub5\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub5.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub6\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub6.php?q=$1 [l,qsa] # friendly urls part rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?q=$1 [l,qsa]
i tried #
last 3 lines, didnt make difference. i've got more lines in htaccess, #
. subdomain create in control panel of server, subdomains ponted same directory (public_html
).
right i'm not sure passing data works, , when go sub1.domain.com apache redirect me www.domain.com/sub1.php, thich wrong.
how link subdomains php files , keep url same (sub1.domain.com)??
remove redundant stuff , keep code this:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^www\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /index.php?q=$1 [l,qsa] rewritecond %{http_host} ^sub1\.domain\.com [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /sub1.php?q=$1 [l,qsa]
Comments
Post a Comment