我想安装HTTPS统治的.htaccess
文件,以便任何人访问我的网站被重定向到https,实现这一点,这是我的 htaccess的
文件看起来像
I am trying to setup https rule in .htaccess
file so whoever access my website gets redirected to https and to achieve this, this is how my htaccess
file looks like
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteRule ^$ https://www.domain.com/%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
以上工作正常,我怎么主页,但如果我直接访问一个页面 domain.com/page
然后不重定向到https
The above works fine how home page but if i access a page directly domain.com/page
then i dont get redirected to https
有人能告诉我我在想什么?
Can someone please tell me what am i missing?
更改重写规则
到
RewriteRule ^ https://www.domain.com/%{REQUEST_URI} [R,L]
的通知,也没有 $
在 ^
,这是有效的,说明重定向,但只有在没有目录的路径信息在IE中重定向URL根 /
只请求。
Notice, there's no $
after ^
, which was effectively stating that redirect but only if no directory path information is found i.e. redirect root URL /
requests only.