Return to Snippet

Revision: 74663
at December 7, 2018 01:15 by cerxx


Initial Code
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} (.*)\.domain\.ru
RewriteCond $1 !^sd_
RewriteRule (.*) /sd_subdomain/%1/$1 [L]

Initial URL
http://backnet.ru/2014/04/29/redirekt-poddomenov-v-papku-na-osnovnom-domene/

Initial Description
There is a domain: domain.ru
There are subdomains subdomain.domain.ru and forum.domain.ru
domain.ru is configured as a host and is located in the folder ... / www / domain /
Subdomains are aliases of the main domain - i.e. lead to the same folder ... / www / domain /
Idea: make subdomains refer to folders, inside the main domain folder, i.e.
subdomain.domain.ru -> ... / www / domain / sd_subdomain / subdomain /
forum.domain.ru -> ... / www / domain / sd_subdomain / forum /
Here is what you need to register in .htaccess

Initial Title
Redirect subdomains to a folder on the main domain

Initial Tags
htaccess

Initial Language
Apache