C
C
ChNataly2014-08-26 12:50:19
htaccess
ChNataly, 2014-08-26 12:50:19

Why does the url in the browser change when creating dynamic subdomains via htaccess?

Good afternoon!
I've been suffering for a week now with a problem... Dynamic subdomains are being formed on the site...
For example, the test.site.com subdomain is physically located in the site.com/subdomains/test/ folder, the
hosting has already been configured, the htaccess file is accepted by all subdomains..
In htaccess the entry is like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.site/? [NC]
RewriteRule (.*) site.com/subdomains/$2$1 [L,QSA]
The problem is that the construction works, but the url changes in the browser.
That is, there is simply a redirect from test.site.com to site.com/subdomains/test/
and it is necessary that this happens unnoticed so that test.site.com remains in the browser
I'm already inclined to believe that these are some specific hosting settings, because everything works on a different hosting.
Thanks in advance for any help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Elena, 2014-08-26
@Nidora

Try doing it like here

RewriteCond %{HTTP_HOST} !^www\.site\.ru$
RewriteCond %{HTTP_HOST} ^(.+)\.site\.ru$
RewriteCond %{REQUEST_URI} !/%1/
RewriteRule ^(.*)$ /%1/sub/$1 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question