【发布时间】:2021-04-04 05:28:51
【问题描述】:
我重定向所有虚拟子域如下。
RewriteCond %{HTTP_HOST} ^(.+)\.mysite\.com$
RewriteRule ^$ subdomain.php?url=%1 [NC,QSA,L]
这样,我从数据库中获取数据。所有“虚拟子域”。但是有一个真正的子域。 Opencart 里面 (shop.mysite.com)
htaccess 也指导这一点。如何防止它仅仅重定向“shop”这个词。
我的完整代码:
Options Indexes SymLinksIfOwnerMatch
RewriteEngine on
directoryindex index.php
Options -indexes
RewriteRule index index.php
RewriteCond %{HTTP_HOST} ^(.+)\.mysite\.com$
RewriteRule ^$ subdomain.php?url=%1 [NC,QSA,L]
# www.site.com >> site.com
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
【问题讨论】:
-
旁白: 你的规则只匹配文档根目录;对吗?
标签: .htaccess subdomain virtual