HTTPS强制重定向不工作在Word preSS [英] HTTPS Force Redirect not working in Wordpress
问题描述
我的话preSS目录是www.mysite.com/blog
My Wordpress directory is at www.mysite.com/blog
最近,我改变了我的整个网站以强制HTTPS。因此,在/博客我的.htaccess文件/看起来是这样的:
I recently changed my entire site to force HTTPS. So my .htaccess file in /blog/ looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
我也改变了网站的网址在Word preSS设置为HTTPS。
I also changed the site URL in Wordpress settings to be HTTPS.
这完全在网页,但在任何页面后,最终用户可以切换到非安全的HTTP,通过改变URL和pressing进入。
This works perfectly in the homepage, but in any post pages, the end user is able to change to non-secure HTTP, by changing the URL and pressing enter.
例如,他们可以直接键入: http://www.mysite.com/blog/post-1/ 它会加载为HTTP。
For example, they can type directly: http://www.mysite.com/blog/post-1/ and it will load as HTTP.
什么是错我的.htaccess文件?在哪里闲着?
What is wrong with my .htaccess file? Where is the loose end?
推荐答案
更改规则的顺序。首先重定向到 HTTPS
,然后让WP接管所有的请求。
Change the order of the rules. First redirect to https
and then let WP take over all of your requests.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
这篇关于HTTPS强制重定向不工作在Word preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!