Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess force http to https

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

    Code:
    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]
    Last edited by Mozzi; 03-24-2011 at 10:09 AM. Reason: SOLVED

  • #2
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved ::

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Mozzi View Post
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    Code:
    RedirectPermanent http://www.mozzi.co.za/ https://www.mozzi.co.za/
    best regards

  • #4
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mmmm

    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://


    Code:
    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

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Mozzi View Post
    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://


    Code:
    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/u....html#redirect

    i would try RedirectMatch permanent.

    best regards

  • #6
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    anyone with a good solution please?

    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

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    something like this?
    Code:
    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

  • #8
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still not working

    still not working...

    I have also tried

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

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Mozzi View Post
    still not working...

    I have also tried

    Code:
    RewriteEngine On  
    RewriteCond %{HTTPS} off  
    RewriteCond %{REQUEST_URI} !^/maps/map\.php$  
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    my last attempt:
    Code:
    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

  • #10
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mmm

    sorry still not working..but thank you for the try

  • #11
    New Coder
    Join Date
    Jan 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    got this

    Code:
    # 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]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •