Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2011, 08:57 AM   PM User | #1
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
.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 09:09 AM.. Reason: SOLVED
Mozzi is offline   Reply With Quote
Old 03-24-2011, 09:08 AM   PM User | #2
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
Solved ::

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Mozzi is offline   Reply With Quote
Old 03-24-2011, 09:11 AM   PM User | #3
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 03-25-2011, 10:12 AM   PM User | #4
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
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
Mozzi is offline   Reply With Quote
Old 03-25-2011, 05:07 PM   PM User | #5
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 05-03-2011, 01:07 PM   PM User | #6
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
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
Mozzi is offline   Reply With Quote
Old 05-03-2011, 06:02 PM   PM User | #7
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 05-04-2011, 09:18 AM   PM User | #8
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
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]
Mozzi is offline   Reply With Quote
Old 05-04-2011, 07:03 PM   PM User | #9
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 05-05-2011, 04:11 PM   PM User | #10
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
mmm

sorry still not working..but thank you for the try
Mozzi is offline   Reply With Quote
Old 05-05-2011, 04:26 PM   PM User | #11
Mozzi
New Coder

 
Join Date: Jan 2010
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Mozzi is an unknown quantity at this point
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]
Mozzi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:37 PM.


Advertisement
Log in to turn off these ads.