htaccess将所有页面重定向到www,除了结帐页面

时间:2012-10-18 05:05:56

标签: regex .htaccess

我有一个ssl的网站,只适用于非www版本。是否可以使用htacess将除了结帐页面之外的所有网址重定向到www版本,并在结帐页面上添加https://

由于

1 个答案:

答案 0 :(得分:0)

说明您的结帐页面位于https://domain.com/checkout.php

尝试:

RewriteEngine On

# redirect non-www hostname to www hostname, but not /checkout.php
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule !^/?checkout.php http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# if checkout.php, redirect if not HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^/?checkout.php https://domain.com%{REQUEST_URI} [L,R=301]