0

我正在尝试将所有流量重定向到 HTTP,除非它是我们的结帐过程,在这种情况下,我正在尝试将其重定向到 HTTPS。

我有一个 Rackspace Cloud Sites 设置,但是下面的设置似乎不起作用。下面有什么我做错了吗?

谢谢!

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php

RewriteEngine On
RewriteBase /

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

#redirect all https traffic to http, unless it is pointed at checkout
RewriteCond %{HTTP:X-Forwarded-SSL} on
RewriteCond %{REQUEST_URI} !^/checkout/?.*$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

#redirect all http traffic to https, if it is pointed at /checkout
RewriteCond %{HTTP:X-Forwarded-SSL} off
RewriteCond %{REQUEST_URI} ^/checkout/?.*$
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
4

3 回答 3

0

另一种方式:

RewriteCond %{HTTPS} !=on
# change user|cart|admin to folders you want SSL on.
RewriteRule ^/?(user|cart|admin) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !=off
# change content|category to folders you want SSL off.
RewriteRule ^/?(content|category) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
于 2013-05-17T21:12:12.143 回答
0

用这个

#redirect all http traffic to https, if it is pointed at /checkout    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} checkout|login
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
于 2014-02-07T13:29:00.650 回答
0
RewriteEngine On
RewriteBase /

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

#Force NON-SSL on a non-checkout directories 
RewriteCond %{ENV:HTTPS} on [NC]
RewriteCond %{REQUEST_URI} !^/DIRECTORY/?.*$
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L]

#Force SSL on a specific directory
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^DIRECTORY/(.*)$ https://www.example.com/DIRECTORY/$1 [R,L]
于 2013-05-17T19:50:36.577 回答