使用htaccess的重定向HTTP到HTTPS的Word preSS? [英] Using htaccess to redirect http to https for Wordpress?

查看:147
本文介绍了使用htaccess的重定向HTTP到HTTPS的Word preSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经正确启用HTTPS重定向与下面的code。 访问HTTPS页面中的一个后,所有其他URL都继承了previous HTTPS。我怎么能强制所有其他页面的HTTP?

 #BEGIN字preSS
< IfModule mod_rewrite.c>

RewriteEngine叙述上
的RewriteCond%{} HTTPS!上
的RewriteCond%{REQUEST_URI} ^(/结帐| /下载| /全部产品)
重写规则^(。*)$ https://websitename.com/$1 [R,L]

RewriteEngine叙述上
的RewriteBase /
重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>
#结束字preSS
 

解决方案

您可以使用:

 #BEGIN字preSS
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /

的RewriteCond%{} HTTPS关闭
的RewriteCond%{REQUEST_URI} ^ /(结帐|下载|全产品)
重写规则^(。*)$ https://websitename.com/$1 [R = 301,L,NE]

的RewriteCond%{} HTTPS上
的RewriteCond%{REQUEST_URI} ^ /!(结帐|下载|全产品)
重写规则^(。*)$ http://websitename.com/$1 [R = 301,L,NE]

重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>
#结束字preSS
 

I've correctly enabled HTTPS redirect with the code below. After visiting one of the HTTPS pages, all other urls are inheriting the previous HTTPS. How can I force all other pages to HTTP?

# BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^(/checkout|/downloads|/all-products)
RewriteRule ^(.*)$ https://websitename.com/$1 [R,L]

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

解决方案

You can use:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/(checkout|downloads|all-products)
RewriteRule ^(.*)$ https://websitename.com/$1 [R=301,L,NE]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/(checkout|downloads|all-products)
RewriteRule ^(.*)$ http://websitename.com/$1 [R=301,L,NE]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

这篇关于使用htaccess的重定向HTTP到HTTPS的Word preSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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