Jump to content

forcing whole website to https but not one url


bambinou1980

Recommended Posts

Hello,

Could anyone tell me how I can force https on my whole website but not on a single folder or url. At the moment I have this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^thatmysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://thatmysite.com/$1 [R,L]

But if I add this second code in the root htaccess to remove https from the /thatsite.com/printing folder, I get a redirect loop because I am forcing on the code http to https and not https to http...

RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{REQUEST_URI} ^\/(printing)
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]

RewriteCond %{HTTP:X-Forwarded-SSL} =on
RewriteCond %{REQUEST_URI} !^\/(printing)
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]

Do you know a way around this please? I have been looking all over the internet and cannot find a single good answer.

 

 

Thank you,

 

Ben

Link to comment
Share on other sites

Someone just gave me a beautiful solution in another forum:

 

RewriteEngine On RewriteCond %{HTTPS} offRewriteCond %{THE_REQUEST} !/printing [NC]RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} onRewriteCond %{THE_REQUEST} /printing [NC]RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 
 
By using this fantastic piece of code I can go on my website and have https all over but not in the folder /printing, just tired it and it works very well.
 
Now it might sounds crazy to you but I have a good reason for this. I have multiple printers which are using 2g communications to communicate with my php order page and php callback page.
The problem with those printers is that they do not work over https(got the message from the manufacturer today s I just could not get them to grab the files in https) and they have told me to force this specific url to http.
 
Now security wise, there are no problem at all because this folder will not be accessible to users and will only be used for printer communications, no login there.
 
Hope you understand now why I needed this so much.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.