。htaccess如果存在,将子域重写到文件夹中

问题描述 投票:0回答:1

我正在尝试将该URL customer1.example.com重写为http://example.com/customer1。使用此代码,一切正常。

RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/%1/$1 [L,R=301]

但是如果根目录目录中不存在条件1 customer1.exemple.com => customer1文件夹存在,因此将其重写为exemple.com/customer1。条件2 customer2.exemple.com => customer2文件夹不存在,因此重写为exemple.com

另一个我认为我需要的是,重写仅覆盖example.com,而不能覆盖服务器上的其他域。

谢谢您的帮助

我正在尝试将此URL customer1.example.com重写为http://example.com/customer1。使用此代码,一切正常。 RewriteCond%{HTTP_HOST} ^(。+)\。example \ .com $ [NC] RewriteCond%{HTTP_HOST}!www ....

.htaccess url-rewriting subdomain
1个回答
0
投票
只需添加此代码:
© www.soinside.com 2019 - 2024. All rights reserved.