Posted By

cerxx on 12/07/18


Tagged

htaccess


Versions (?)

Redirect subdomains to a folder on the main domain


 / Published in: Apache
 

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

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 / sdsubdomain / subdomain / forum.domain.ru -> ... / www / domain / sdsubdomain / forum / Here is what you need to register in .htaccess

  1. RewriteEngine On
  2. RewriteBase /
  3.  
  4. RewriteCond %{HTTP_HOST} !^www\.
  5. RewriteCond %{HTTP_HOST} (.*)\.domain\.ru
  6. RewriteCond $1 !^sd_
  7. RewriteRule (.*) /sd_subdomain/%1/$1 [L]

Report this snippet  

You need to login to post a comment.