The .htaccess contains the instructions for redirecting all variants of writing the site address to the main domain https://mysite.ru .:
RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. RewriteRule (.*) https://mysite.ru/$1 [L,R=301] I would also like to implement redirecting subdomains to the appropriate folder. The instruction works well on ordinary http-domains:
RewriteCond %{ENV:REDIRECT_VHOST} ^$ RewriteCond %{HTTP_HOST} ^(.+)\.mysite\.ru$ RewriteRule ^(.*) %1/$1 [L,E=VHOST:1] However, in my case, the two redirects naturally conflict, and subdomains do not work. I can’t figure out how to combine them together - (the “before” or “after” permutation, of course, does not work). For example, the addresses: https://sub.mysite.ru , http://sub.mysite.ru , www.sub.mysite.ru redirected as it should be to https://mysite.ru/sub .
The following instruction does not work :
RewriteEngine on RewriteBase / # переадресация субдоменов RewriteCond %{ENV:REDIRECT_VHOST} ^$ RewriteCond %{HTTP_HOST} ^(.+)\.mysite\.ru$ RewriteRule ^(.*) %1/$1 [L,E=VHOST:1] # переадресация на https: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. RewriteRule (.*) https://mysite.ru/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,NS]