简体   繁体   中英

Redirect to subdirectory from multiple domain

I have multiple domain that point to the same server. Then i need to separate it to different directory. how to make it in htaccess or other way.

Here an example.

domain1.com show 1.2.3.4/abc
domain2.com show 1.2.3.4/def
domain3.com show 1.2.3.4/ghi
...

You can use these type of rules in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule !^abc/ /abc%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC]
RewriteRule !^def/ /def%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^domain3\.com$ [NC]
RewriteRule !^ghi/ /ghi%{REQUEST_URI} [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM