的.htaccess的SSL? [英] .htaccess for SSL?

查看:109
本文介绍了的.htaccess的SSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

RewriteCond %{HTTP_HOST} ^MYDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://www.MYDOMAIN.com/$1 [L,R=301]

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^/(user|admin|cart)
RewriteRule ^(.*)$ https://www.MYDOMAIN.com/$1 [R=301,L] 

这有效地路由所有/用户/管理员和/车路径使用SSL。我的问题是逆。我需要指出,如果你是不是在这些网页上,这将您重定向到HTTP(无SSL)的规则。

This effectively routes all /user and /admin and /cart paths to use SSL. My problem is the inverse. I need a rule that states that if you are NOT on those pages, that it redirects you to HTTP (no SSL).

我该怎么办呢?

推荐答案

第一件事,清除浏览器缓存完全和重新启动浏览器。然后用这个代替你的.htaccess:

First thing clear your browser cache completely and restart your browser. Then replace your .htaccess with this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^MYDOMAIN\.com$ [NC]
RewriteRule ^ http://www.MYDOMAIN.com%{REQUEST_URI} [L,R]

RewriteCond %{HTTPS} !=on
RewriteRule ^(user|admin|cart)(/.*|)$ https://www.MYDOMAIN.com%{REQUEST_URI} [R,L,NC]

RewriteCond %{HTTPS} =on
RewriteRule (?!^(user|admin|cart)(/.*|)$)^.*$ http://www.MYDOMAIN.com%{REQUEST_URI} [R,L,NC]

这篇关于的.htaccess的SSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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