LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-17-2012, 02:34 AM   #1
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Rep: Reputation: 1
redirect http to https


hi,

i configured ssl over http, every thing is fine and working fine, issue is my site is also working with www.mydomain.com it's working with http, so i commented LISTEN 80. so it's not opening with http. now type www.mydomain.com it's not opening, i have to type https manually infront of it. is there any way so that if i type www.mydomain.com, it will automatically redirected to https://www.mydomain.com

i'm using apache on rhel6

thanks in advance.
 
Old 06-17-2012, 03:52 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi Gil@LQ,

You can use mod_rewrite for this. You need to go in the http vhost container and add the following:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Regards
 
Old 06-18-2012, 09:43 AM   #3
montel
Member
 
Registered: Jun 2012
Location: Canada
Distribution: Ubuntu/Debian/CentOS
Posts: 45

Rep: Reputation: 19
I have something similar that is forwarding all traffic to https.

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

Good luck
 
Old 06-18-2012, 03:04 PM   #4
Gil@LQ
Member
 
Registered: Apr 2010
Location: India /Hyderabad
Distribution: RedHat, CentOS
Posts: 273

Original Poster
Rep: Reputation: 1
Thank you all for your replies.

it worked thank you very much.

gil@lq
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with http:// to https:// redirect PLEASE reaper75 Linux - Newbie 3 03-31-2012 04:57 PM
Redirect HTTP to HTTPS: bates Linux - Server 4 10-01-2010 11:10 AM
redirect http to https nagavinodh Linux - Newbie 3 09-24-2009 08:34 AM
How to redirect http to https? Sovan Linux - Server 1 12-03-2008 01:11 PM
redirect http to https awreneau Linux - Server 17 10-14-2008 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:34 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration