D
D
Dmitry2015-07-01 10:04:31
htaccess
Dmitry, 2015-07-01 10:04:31

Redirecting requests from a subdomain to a domain virtual folder?

There is a task to organize a subdomain for each user. For example user-name.site.ru
There are a lot of articles on the net that describe how to do this, but something doesn’t work for me. The site is written using mvc. At the moment, in htaccess, the following code is
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
Please tell me using site.ru/ as an example forum how to do it, then I myself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tlito, 2015-07-01
@tlito

1. you need to enable Wild-cards for the domain in the hosting settings, that is, add the domain *.site.ru
2. You need to do the redirect correctly, for this you need to configure .htaccess in the site.ru root - for this you need to study the Redirect 301 example and try , and on some hostings, changes in .htaccess do not always work instantly (there is caching there)
3. in my opinion there is a solution coderhs.com/archive/redirect_301#poddomen
RewriteCond %{HTTP_HOST} ^(.*).site.ru $ [NC]
RewriteRule ^(.*)$ http://site.ru%{REQUEST_URI} [R=301,NC,L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question