apache - How do I route all subdomains to index.php using htaccess without 301 redirect -
i set htaccess file routes requests subdomain index.php file in /public_html/ folder. have configured dns accept wildcard subdomains.
i plan give users personalised url site , pass username via subdomain, important url remains , hence 301 redirects out of question.
my htaccess looks this, not work (server not found):
rewriteengine on rewritecond %{http_host} ^(.+)\.mydomain\.com$ [nc] rewriterule . /index.php?subdomain=%1 [l,qsa]
my end goal able url such //joebloggs.mydomain.com/foo/bar
translate //www.mydomain.com/index.php?user=joebloggs&route=/foo/bar
.
what need have in htaccess file make work?
you can have way
# if request subdomain (except "www") rewritecond %{http_host} ^((?!www\.).+)\.mydomain\.com$ [nc] # internally rewrite index.php rewriterule ^((?!index\.php$).*)$ /index.php?subdomain=%1&route=$1 [l]
Comments
Post a Comment