Answer the question
In order to leave comments, you need to log in
How to implement a subdomain redirect to a site section via .htaccess?
It is necessary to make sure that when visiting user.example.com, the page example.com/user opens, but not just redirects to this address, but that the subdomain address remains in the browser.
Answer the question
In order to leave comments, you need to log in
I do this, but the address in the browser changes to site.com/user
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^user.site.com [NC]
RewriteRule ^/(.*)$ /user/$1 [L]
I did this, placed the rule at the root:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^coffee.
RewriteRule ^(.*)$ /projects/coffee/www/$1 [L]
RewriteEngine on
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?id=$1 [QSA,L]
I did it like this, you put the necessary directories in the subdomains directory, and the request from the subdomains goes to the appropriate one.
<IfModule mod_rewrite.c>
RewriteEngine on
# Subdomains
RewriteCond %{REQUEST_URI} !^/subdomains
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.ru$
RewriteRule ^(.*)$ /subdomains/%1/$1 [L,QSA]
</IfModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question