Z-blog如何强制https访问

Apache + .htaccess

可以在.htaccess文件中添加以下规则来强制https访问:

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

修改过的.htaccess文件如下:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

 # 添加以下规则以强制使用HTTPS

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


相关文章

最新主题