0

我有这个 URL http://www.mysite.com/checkout/payment,好吧,我创建了一个文件 htaccess 来重定向这个页面,当 URL 与“checkout/payment”不同时,URL 变成了一个普通的 http。

但是一旦出现问题,资产(JS、CSS、JPG、PNG)总是被重定向到正常的 HTTP,我该如何解决这个问题?

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(checkout/pay)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (checkout/pay)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
4

1 回答 1

0

请尝试以下规则:

# Redirect checkout pay(ment) pages to https 
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/checkout/pay [NC]
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

# Redirects all resources where the http referer field matches the checkout payment page.
# Weirdly enough I can't seem to use any server variables in the http referer regex. Please change it to match your host.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_REFERER} ^https://www.mysite.com/checkout/pay [NC]
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
于 2013-02-21T20:30:35.043 回答