![](/img/trans.png)
[英].htaccess re-write rules for apache server, containing usernames as subdomains
[英]How to exclude subdomains from re-write rules in htaccess
在我的htaccess文件中,我有以下代码:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
我想这样做,以便在输入子域时不会将其重写为www.sub.domain.com,而只是将其重写为sub.domain.com。 我已经玩了好几次了,似乎还没做好。 有什么想法吗?
您可以尝试以下规则:
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
现在它将把domain.com
重定向到www.domain.com
但将跳过sub.domain.com
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.