Jump to content

Need encryption for some bits and not others


kevintynfron

Recommended Posts

Hi all,

 

We have a website where we want users to browse unencrypted for most of it, but move to encrypted when they move to other areas. We also want to make sure all URI start www.

 

at the moment, .htaccess in the httpdocs root has the following

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.example.co.uk$
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301]

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} operator [OR]
RewriteCond %{REQUEST_URI} your_account [OR]
RewriteCond %{REQUEST_URI} buy_tickets/checkout [OR]
RewriteCond %{REQUEST_URI} sell_tickets
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R,L]

 

I'm guessing that it's the first rewrite rule that's doing it with the "https". Does it then carry on after the re-write onto the second?

 

On another note, would I be better off putting this in httpd.conf somewhere?

 

I have been trying to test this, but am having real problems getting mod_ssl going on my test platform (but that's another story....) so thanks for any help.

 

Cheers,

Kevin

 

RewriteCond %{HTTP_HOST} !^www.example.co.uk$

RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301]

 

 

In pseudo-code says:

 

if(the host is exactly equal to "www.example.co.uk") {

    rewrite anything to https://www.example.co.uk/anything with a 301 header

}

Thanks corbin.

 

if(the host is exactly equal to "www.example.co.uk") {

 

Isn't that "if (the host is not exactly equal to "www.example.co.uk") {" ? I thought the '!' was a NOT operator

 

In which case presumably changing the https to http would work.

This seems like a bit of a quick'n'dirty way to do it, not that I know of any other way. Is there another way that anyone knows of?

 

Cheers,

Kevin

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.