kevintynfron Posted December 2, 2008 Share Posted December 2, 2008 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 Quote Link to comment Share on other sites More sharing options...
corbin Posted December 2, 2008 Share Posted December 2, 2008 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 } Quote Link to comment Share on other sites More sharing options...
kevintynfron Posted December 2, 2008 Author Share Posted December 2, 2008 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 Quote Link to comment Share on other sites More sharing options...
corbin Posted December 3, 2008 Share Posted December 3, 2008 Ahhh sorry, didn't see the ! when I was typing that ;p. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.