.htaccess - Apache wildcard subdomains with url masking -
i trying handle wildcard subdomains url masking in apache. correct rewrite rules should achieve following:
http://demo.system.dev to http://system.dev?subdomain=demo
http://sample.system.dev/user/edit/100 to http://system.dev/user/edit/100?subdomain=sample
http://debug.system.dev/project/edit/new to http://system.dev/project/edit/new?subdomain=debug
so far have following rule in .htaccess
rewritecond %{http_host} ^(.*)\.system\.dev rewriterule ^(.*?)$ http://system.dev%{request_uri}?subdomain=%1 [l] which looks working ok except browser url changed. browser url remain same , internally route request not sure how achieve this.
try rule in root .htaccess:
rewriteengine on rewritebase / rewritecond %{query_string} !(?:^|&)subdomain= [nc] rewritecond %{http_host} ^([^.]+)\.system\.dev$ [nc] rewriterule (.*) $0?subdomain=%1 [l,qsa]
Comments
Post a Comment