Forum Moderators: phranque
I have a domain hosted at GoDaddy on a dedicated server. I have my website running under http and want to add https for a shopping cart. I want all traffic to my domain to be http unless it's using the shopping cart and then I want to run it over https. i've added the following rewrite rules to the file /etc/httpd/conf.d/zz010_psa_httpd.conf write below the document root definition.
#
RewriteEngine on
# Send http shopping cart request to https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(ShopCart¦ShopCart/)$ [example.com...] [R=301,L]
#
# Send https pages to http unless the shopping cart is referenced.
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^/(ShopCart¦ShopCart/)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
##
I restart the server and there are no errors. Whenever I access the https port I get the same default https page I had before the server restart. Does the rewrite clauses need to be inserted at another place? Accessing the store via http or any part of the site via https does not provide the anticipated redirection. How can I resolve this issue and determine why my rewrite does not work.
[edited by: jdMorgan at 5:15 am (utc) on July 19, 2007]
[edit reason] example.com [/edit]
1) Unless the URL-path is always exactly /ShopCart or /ShopCart/ --nothing more, nothing less-- then your patterns won't match because they are end-anchored and trailing path info is neither recognized nor retained. Note also that the pattern "ShopCart¦ShopCart/" can be more efficiently written as "ShopCart/?
2) URL-paths seen by RewriteRules in httpd.conf or conf.d will all start with "/", unlike those in .htaccess. This will prevent your first RewriteRule pattern from matching. Also, be careful to avoid creating duplicate slashes, as in your second rule.
3) It is common --and therefore likely in this case-- to have a separate container for the SSL part of things -- make sure your code is placed where it applies to both port 80 and port 443 connections.
Just a few things to check...
Jim