...

View Full Version : .htaccess force http to https



Mozzi
03-24-2011, 09:57 AM
I want my domain. www.mozzi.co.za to automailty redirect a https instead of http

im very new at this.. so a helping hand would be great please.

I need this...
www.mozzi.co.za/secure/cars/ once I get to this directory it mus check if its http or https.. if http then htaccess must make it https....



RewriteEngine on

# Ensure correct host
RewriteCond %{HTTP_HOST} www.mozzi.co.za/secure/cars
RewriteRule (.*) https://www.mozzi.co.za/secure/cars/$1 [R=301]

Mozzi
03-24-2011, 10:08 AM
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

oesxyl
03-24-2011, 10:11 AM
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}



RedirectPermanent http://www.mozzi.co.za/ https://www.mozzi.co.za/


best regards

Mozzi
03-25-2011, 11:12 AM
thank you OESXYL :) :)

But now I have a page that uses a IFRAME from google maps...

And now I get security messages all the time...

Is there anyway to to exclude say map.php so that is can use http??? and not have to go https://




RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RedirectPermanent https://www.mozzi.co.za/maps/map.php http://www.mozzi.co.za/maps/map.php

oesxyl
03-25-2011, 06:07 PM
thank you OESXYL :) :)

But now I have a page that uses a IFRAME from google maps...

And now I get security messages all the time...

Is there anyway to to exclude say map.php so that is can use http??? and not have to go https://




RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RedirectPermanent https://www.mozzi.co.za/maps/map.php http://www.mozzi.co.za/maps/map.php

i'm not sure if this will help:

http://httpd.apache.org/docs/trunk/urlmapping.html#redirect

i would try RedirectMatch permanent.

best regards

Mozzi
05-03-2011, 02:07 PM
so it needs to force the site... to be https if its http...

but exclude the link or page map.php for this forces https and map nees to be on a http link

oesxyl
05-03-2011, 07:02 PM
something like this?


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{PATH_INFO} !-fmap.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

i'm not sure if you need to use %{PATH_INFO} and if -fmap.php will match the given url but the idea is to negate something wich match the url you want to exclude so that the RerwiteRule to be applied only if both condition are true.

best regards

Mozzi
05-04-2011, 10:18 AM
still not working...

I have also tried



RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/maps/map\.php$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

oesxyl
05-04-2011, 08:03 PM
still not working...

I have also tried



RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/maps/map\.php$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
my last attempt:


RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maps/map\.php
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

try map url first, remove $ to not match exactly and then the rest.

best regards

Mozzi
05-05-2011, 05:11 PM
sorry still not working..but thank you for the try :)

Mozzi
05-05-2011, 05:26 PM
got this



# Redirect everything non-HTTPS to HTTPS, unless its an include file, belongs to a different subdomain, or is the google-map page
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} !=test.mozz.co.za
RewriteCond %{HTTP_HOST} !=oldsite.mozzi.co.za
RewriteCond %{REQUEST_URI} !(.*css)
RewriteCond %{REQUEST_URI} !(.*js)
RewriteCond %{REQUEST_URI} !(.*gif)
RewriteCond %{REQUEST_URI} !(.*png)
RewriteCond %{REQUEST_URI} !(.*jpg)
RewriteCond %{REQUEST_URI} !(maps/documents)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

#If HTTPS, redirect Google Map page to non-HTTPS
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} (maps/documents)
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [R=301,L]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum