简体   繁体   English

从多个域重定向到子目录

[英]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. 如何用htaccess或其他方式制作它。

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: 您可以在DOCUMENT_ROOT/.htaccess文件中使用以下类型的规则:

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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