如何强制https到特定的URL和其他URL不?

时间:2014-07-19 11:04:17

标签: apache .htaccess

我想强制https用于以下两个网址:

  1. http://secure.gopopal.com/paymentstep.php
  2. http://secure.gopopal.com/registername.php
  3. 并且所有其他网址都使用http。

    我应该如何使用.htaccess?

    由于

1 个答案:

答案 0 :(得分:0)

尝试:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^secure\.gopopal\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(paymentstep|registername)\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

#if needed, everything else
RewriteCond %{HTTPS} on
RewriteRule !^(paymentstep|registername)\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R]