Trying to redirect from http to https using .htaccess

Hi there,

One of my clients purchased a 1-year SSL certificate for one of his sites.  It's a one-click checkout process.  He had some development work done to hook it up to authorize.net's payment gateway.  Anyways, I registered the certificate and I am currently trying to force a redirect to https if someone tries to access the http URL for the checkout page.

This is what I have :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule http://www.somesite.com/checkout.php https://%{HTTP_HOST}%{REQUEST_URI}

Open in new window


It's not working as far as I can tell.  I've cleared the browser cache multiple times and it's a no-go.  

Am I doing this right?
duder78Asked:
Who is Participating?
 
Frederic SuneCEO, IT in MIND inc.Commented:
Try this:

RewriteCond %{SERVER_PORT} =80
RewriteRule ^checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
0
 
grahamnonweilerCommented:
Are you sure "mod-rewrite" is enabled in Apache?

Do you have any other .htaccess files working?

Also try  either of the below:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$  https://%{HTTP_HOST}/$1 [L,NC]

Open in new window

- or -
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^/checkout.php$  https://%{HTTP_HOST}/checkout.php [L, NC]

Open in new window

0
 
arober11Commented:
Or if your after a rule that will work in either the httpd.conf or a .htaccess file and is not case sensitive try:

RewriteEngine On
RewriteCond %{HTTPS}        off
RewriteCond %{REQUEST_URI}  ^/checkout\.php$        [NC]
RewriteRule .               https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Open in new window

0
 
duder78Author Commented:
That did it, perfect.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.