htaccess重定向到https:// www子页面

时间:2018-07-27 08:05:48

标签: .htaccess redirect https

我已经成功为网站的基本URL实施了https://www,但是,我注意到,由于仅www被强制实施,因此我能够访问不安全的子页面。

例如,如果我输入www.website/services/,则不会强制执行HTTPS。

这是我正在使用的:

# Redirect from the `http://` to the `https://` version of the URL.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

#rewrite example.com → www.example.com

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{SERVER_ADDR} !=127.0.0.1
  RewriteCond %{SERVER_ADDR} !=::1
  RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

任何帮助将不胜感激。

0 个答案:

没有答案
相关问题