[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Trying to redirect from http to https using .htaccess

Posted on 2012-08-29
4
Medium Priority
?
425 Views
Last Modified: 2012-08-29
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?
0
Comment
Question by:duder78
4 Comments
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 38347107
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
 
LVL 7

Accepted Solution

by:
Frederic Sune earned 2000 total points
ID: 38347123
Try this:

RewriteCond %{SERVER_PORT} =80
RewriteRule ^checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
0
 
LVL 26

Expert Comment

by:arober11
ID: 38347450
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
 

Author Closing Comment

by:duder78
ID: 38347682
That did it, perfect.  Thank you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question