Checking if SSL in PHP code vs. mod_rewrite

A

Anonymous

Guest
Well, I know that mod_rewrite is the best way to do it and is much easier than adding code to many pages checking if secure.

So far, I have this in my .htaccess

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^.*/admin/.* [OR]
RewriteCond %{REQUEST_URI} ^.*/view-quote.php.* [OR]
RewriteCond %{REQUEST_URI} ^.*/process-booking.php/.*
RewriteRule ^/(.*) https://www.securedomain.co.nz/mydir/$1 [L,R]

To redirect admin/, view-quote and process-booking to the shared secure domain I use. Doesn't seem to work - I managed to get ridd of all errors that were returned but now it just does nothing.

I've Googled everywhere, but nothing else seems to work. Any suggestions?
 
I guess your redirect conditions aren't right.
Perhaps you have to turn your redirection code lines from RewriteCond to RewriteRule.
However, you may try first a general redirection.
Example:
Code:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
You can also try this way:
Code:
<IfModule !mod_ssl.c>
  RedirectMatch /(.*)$ https://www.yoursite.com/$1
</IfModule>
Note that this is a general redirection test.
 
Back
Top