ste*_*y68 2 php apache .htaccess mod-rewrite redirect
目前,我的 htaccess 文件将我所有子域的非 https 请求重定向到 https... 除了 www 请求。即http://subdomain.example.com被重定向到https://subdomain.example.com(这是正确的),但www.subdomain.example.com重定向到https://www.subdomain.example.com(不正确)。这是我的 .htaccess 代码:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Trying to redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
尝试改变这个:
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
Run Code Online (Sandbox Code Playgroud)
到
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{HTTP_HOST} ^(?:www\.|)(.+\.example\.com)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2537 次 |
| 最近记录: |