重定向字preSS网站到https的作品,但不是网页和帖子 [英] redirecting wordpress site to https works but not for pages and posts

查看:154
本文介绍了重定向字preSS网站到https的作品,但不是网页和帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装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.

这篇关于重定向字preSS网站到https的作品,但不是网页和帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆