Answer the question
In order to leave comments, you need to log in
Mod_rewrite regex for subdomain?
There are domains en.auto.lc, auto.lc, en.auto.mstarproject.com, auto.mstarproject.com
It is necessary that the “en” parameter be passed to QUERY_STRING on the server, preferably. You can transfer the entire HTTP_HOST, in PHP I will destroy this parameter.
I'm tinkering, it just doesn't work. Here's roughly what you need:
RewriteCond %{HTTP_HOST} ^en\.auto\.(.*)$<br/>
RewriteCond !%{QUERY_STRING} (.*)locale_subdomain(.*)<br/>
RewriteRule ^(.*)$ /$1&locale_subdomain=%{HTTP_HOST}<br/>
Answer the question
In order to leave comments, you need to log in
You just need to change the rewrite conditions from QUERY_STRING to HTTP_HOST:
RewriteCond %{HTTP_HOST} ^(en)\.auto\..+$
RewriteRule ^(.*)$ /$1&locale_subdomain=%{HTTP_HOST}
So you have a host and so in php it will be in $_SERVER, if the domains are configured for one folder - and then sort it out as it should.
Isn't it easier to sort it out at the level of the router of the framework?
This is how it turned out, only somehow long to list all the folders that are on the server and can potentially appear:
RewriteCond %{REQUEST_URI} !^/[^\/]+.php
RewriteCond %{REQUEST_URI} !^/[^\/]+.xls
RewriteCond %{REQUEST_URI} !^/image/
RewriteCond %{REQUEST_URI} !^/imbbank/
RewriteCond %{REQUEST_URI} !^/robots.txt
RewriteCond %{REQUEST_URI} !^/mpanel/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/libp/
RewriteCond %{REQUEST_URI} !^/single/
RewriteCond %{HTTP_HOST} ^en\.auto\.(.*)$
RewriteCond %{QUERY_STRING} !(.*)locale(.*)
RewriteRule ^(.*)$ /?locale=en&%{QUERY_STRING}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question