Regex 如何将HttAccess子域重定向写入https
如何编写htaccess规则,将example.com重定向到www.example.com,并且我们有很多子域,例如subdomain.example.cpm,所以我需要将其重定向到。但当我编写htaccess规则时,它会循环。请发送如何为此编写条件。将此代码放入您的Regex 如何将HttAccess子域重定向写入https,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,如何编写htaccess规则,将example.com重定向到www.example.com,并且我们有很多子域,例如subdomain.example.cpm,所以我需要将其重定向到。但当我编写htaccess规则时,它会循环。请发送如何为此编写条件。将此代码放入您的文档\u ROOT/.htaccess文件: RewriteEngine On # example.com to www.example.com RewriteCond %{HTTP_HOST} ^example\.com$ [
文档\u ROOT/.htaccess
文件:
RewriteEngine On
# example.com to www.example.com
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# http to https for subdomains
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]