I have as SSL enabled website.
Issue : I want that http will redirect to https only for checkout pages.
I am using following code for redirection:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
but it redirects all http to htaccess.
What I Want : I want to put some condition on htaceess so that only ch开发者_StackOverflow社区eckout pages will redirect to https otherwise no redirection will be done.
you have to catch the requests for your checkout pages coming on port 80
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} your-checkout-uri-pattern
RewriteRule ^(.*)$ https://your-sslized-site/$1 [R,L]
The below piece of code solves my problem (when i was using it in api). It might also slove your problem. Give it a try.
Here you go,
# For redirecting HTTP to HTTPS, comments are line by line
# below line checks for https flag
RewriteCond %{HTTPS} off
# below line excludes the mentioned URIs from redirection
RewriteCond %{REQUEST_URI} !^/(myFirstUri|mySecondUri|myThirdUri)
# below line redirects all other URIs except the ones that are mentioned above
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
So, whats happening here is that all my requests will be re-directed to https except the below ones
abc.123/myFirstUri will become http://abc.123/myFirstUri
abc.123/myFirstUri/qw/etc will also be re-directed as stated above
And the others requests will be re-directed to https e.g
abc.123/test becomes https://abc.123/test
精彩评论