Answer the question
In order to leave comments, you need to log in
Automatic subdomains, how to correctly merge 2 pieces of .htaccess code?
Hello. I shoveled a bunch of manuals, talked to technical support, as a result I have some idea, but still I need your help in bringing the .htaccess code to mind.
I am hosted on a virtual server - freehost.com.ua . Here is what they write for automatic subdomains - freehost.com.ua/faq/faq/kak-aktivirovat-optsiyu-ne... . Those. all folders in the root of the main domain become subdomains - nonsense! Technical support suggested that you can create a subdomains folder at the root and add subfolders to it, they will be subdomains. The option is what you need, here is their corrected version of the .htaccess code .
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} !^$
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^([^.]*)\.example\.com$
RewriteCond %{REQUEST_URI} !^/subdomains
RewriteRule ^(.*)$ /subdomains/%1/$1 [QSA,L]
#Устанавливаем кодировку сайта
AddDefaultCharset utf-8
#Переадресации при разных ошибках
ErrorDocument 403 http://example.com/
ErrorDocument 404 http://example.com/
#Скрываем содержимое папок
Options All -Indexes
#Включаем преобразование ссылок
RewriteEngine on
#Склеиваем www с основным доменом
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
#Склеиваем index.php с доменом
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]
#Принудительная подстановка замыкающего слеша
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
#Ловим переменные из урл
RewriteRule ^(.*)(\/|\.html)$ index.php?data=$1&last=$2 [L,QSA]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question