www + http 到 https 转发
www + http To https forward
我想转发这样的请求
http://www.website.com/ > https://www.website.com/ > https://website.com/
我的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
尝试:
RewriteCond %{HTTP_HOST} !^website\.com$
RewriteRule ^ https://domain\.com [R=301,L]
根据您显示的示例,尝试一下。请确保在测试 URL 之前清除浏览器缓存。确保将 https 规则放在 htaccess 文件的顶部。
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我想转发这样的请求
http://www.website.com/ > https://www.website.com/ > https://website.com/
我的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
尝试:
RewriteCond %{HTTP_HOST} !^website\.com$
RewriteRule ^ https://domain\.com [R=301,L]
根据您显示的示例,尝试一下。请确保在测试 URL 之前清除浏览器缓存。确保将 https 规则放在 htaccess 文件的顶部。
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>