Jump to content
Larry Ullman's Book Forums
MikeMikeMike

Link Rewrite In Htaccess For Ssl

Recommended Posts

Larry gives us the following code to write links for SSL access

 

RewriteCond %{HTTPS} off
RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]

 

the problem is that I'm on a shared server .This means that

 

https://titanicraisins.com/checkout.php

 

actually needs to be

 

https://titanicraisins.c8.hostexcellence.com/checkout.php

 

see live example here https://titanicraisins.c8.hostexcellence.com/checkout.php?session=72cac503b52a73308af0508fe462090a

 

but I can't figure out how to change the htaccess file so that it does the rewrites

 

For example, I tried both of the following, neither of which worked.

 

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://example.c8.hostexcellence.com/$1 [R=301,L]

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{example.c8.hostexcellence.com}/$1 [R=301,L]

 

 

Any ideas?

 

 

Also, I'm presuming that the htaccess file is the only place I would need to make the change, right? In other words, if a file in the application has the link www.titanicraisins.com/checkout.php then I don't have to change that link in the application because it gets rewritten in the htaccess file?

Share this post


Link to post
Share on other sites

Strangely, this code is successfully rewriting for files accessed in the admin directory but not for the others, like checkout.php . Any ideas why?

 

RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://titanicraisins.c8.hostexcellence.com/$1 [R=301,L]

Share this post


Link to post
Share on other sites

Okay, so first, what you've done here in the second example is what I would have recommend. I'm not sure why you were using "example" in your previous attempt. As for this second attempt, when you say it's not working for checkout.php and those, what does happen? What doesn't happen? Do you have checkout.php and the others in the proper location (i.e., you probably need to move them to somewhere else on your server for them to be available via HTTPS)?

Share this post


Link to post
Share on other sites

I originally used example.com just to avoid putting my own domain on a public forum.

 

With checkout.php, instead of creating a link like this https://titanicraisins.c8.hostexcellence.com/checkout.php?session=72cac503b52a73308af0508fe462090a

 

it's just creating the regular url www.titanicraisins.com/checkout.php, but when I try to visit that link (i.e. to checkout), my browser gives me a warning about the link that it could not be verified and there is an https: in red letters in the url bar.

 

I don't know on what basis you say checkout.php has to be moved somewhere else on my server. That wasn't the case for any of the admin files, and my host provider didn't say anything about that.

Share this post


Link to post
Share on other sites

If you are using a shared SSL, the one provided by your host free of charge versus using your own SSL certificate you will get warnings and so will your visitors because the SSL is not tied specifically to your domain. Shared SSL's CAN'T be tied to a domain it is tied I believe to the server itself? Not sure.

 

If you get your own SSL specific to your domain then you also won't have to monkey with the code to make it work with the shared SSL url.

  • Upvote 1

Share this post


Link to post
Share on other sites

What browser are you using?

 

I misread your post, I thought you were trying to get the URL to be your domain and not the shared hosting SSL URL.

 

I visited the link in your post in FF4 and IE8 and it worked for me and was the shared SSL url. If it isn't for you possibly your cache needs to be cleared?

 

Edit: For me in the browsers it is Blue not Green, but the LOCK is shown in IE but not in FF4 but FF4 I think shows it different. When I hover my mouse over the blue portion of the URL I get a popup that it is verified.

 

 

thanks Terry, but that's not true. The SSL is working on the admin folder files, without giving a warning. The https is green.

 

It's checkout.php that's not working.

Share this post


Link to post
Share on other sites

Terry, the link in the post works because that was manually created. However, if you click the checkout link in the application so that the URL is dynamically generated to checkout.php with SSL, then it doesn't create the https url. (note, that is not the case for the admin pages. That SSL/https url is working fine)

 

I'm using Chrome and firefox

Share this post


Link to post
Share on other sites

I understand now.

 

In the redirect, this part

 

%{HTTP_HOST}

 

Needs to be replaced with

 

titanicraisins.c8.hostexcellence.com

 

The reason is

 

%{HTTP_HOST} is your website URL titanicraisins.com

 

That SHOULD work, but you say that this does not. I would contact your host and tell them the issue and see if they can suggest something.

Some hosts require SSL accessed files to be in a special folder, some hosts do not.

 

I can't help anymore at this stage because this should be working, either there is more to this than you are sharing more lines and redirects in the htaccess or you need to place checkout.php and others into a special folder or there is not something configured right somewhere with your account. I don't know, all I can suggest at this stage is to contact your host.

Edited by Terry

Share this post


Link to post
Share on other sites

..The SSL is working on the admin folder files, without giving a warning. The https is green.

 

This confuses me.

 

In the admin folder you must have the shared url hard coded somewhere because your domain name url doesn't have an SSL.

 

If you change the main htaccess file as mentioned above it all should be working under the shared url including the admin folder.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...