LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 01-19-2005, 11:24 AM   #1
OneSeventeen
Member
 
Registered: Oct 2004
Location: Albuquerque, NM
Posts: 41

Rep: Reputation: 16
Apache 2: forward http to https?


I need to forward all requests from http://example.com to https://example.com

The site always starts on the same page (as it has only one function), so I have no need for elaborate rewrite scripts or anything, just basically any request to http://www.example.com/foo/bar/baz.php be forwarded to https://www.example.com/

I am using mod_ssl with apache 2 on a mandrake 10.0 machine.

I was thinking of adding:
Code:
RewriteEngine        on
RewriteCond          %{HTTPS} !=on
RewriteRule          .* - [F]
But I honestly don't know what that does, or if it would work (I just grabbed it from an ssl HOWTO on apache's site.)

Any tips?

Last edited by OneSeventeen; 01-19-2005 at 11:25 AM.
 
Old 01-19-2005, 01:51 PM   #2
OneSeventeen
Member
 
Registered: Oct 2004
Location: Albuquerque, NM
Posts: 41

Original Poster
Rep: Reputation: 16
We have a winner!
Code:
  RewriteEngine On
  RewriteCond %{SERVER_PORT} ^80$
  RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
Works like a charm, and even does all the crazy url rewriting I didn't need, so if someone changed their current page, however deep into the app they are, to http:// it will automagically change it to https.



I googled "apache rewrite http to https" to find it. ("Redirect" was just a bad word I guess, so after trying a few other searches, I finally found something.)
 
Old 07-03-2006, 07:10 AM   #3
rino.caldelli
Member
 
Registered: Apr 2005
Location: perugia
Distribution: ubuntu
Posts: 181

Rep: Reputation: 31
I use the code above in httpd.conf file but it doesn't work with my https server
I still have to use https://url
Any idea why the rewrite doesn't work???
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http-->https not working realos Linux - Networking 3 07-03-2006 07:15 AM
http and https wennie Linux - Software 1 04-01-2005 11:47 AM
Apache as proxy for http & https queries gosha Linux - Networking 0 07-21-2003 07:41 AM
HTTP to HTTPS shegde Linux - Software 8 01-31-2003 04:29 AM
https or http? antken Programming 3 10-30-2002 05:06 PM


All times are GMT -5. The time now is 09:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration