LinuxQuestions.org
Review your favorite Linux distribution.
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 11-10-2008, 11:02 AM   #1
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
Apache Rewrite


Hi
i want to setup my ssl vhost and i have a bit of a problem
first i want to redirect the links to home page if its not secure
e.g
http://secure.myserver.com should go back to http://myserver.com
but
https://secure.myserver.com should stay on https://secure.myserver.com
and when on the https or secure link if they leave the pages that are secure they should be redirected back to http://myserver.com
i am using fedora 9 64bit
also i have alot of rewrites in there for the alias domains i have and i want it to affect all the
 
Old 11-10-2008, 02:42 PM   #2
mazhar_theone
LQ Newbie
 
Registered: Mar 2008
Posts: 14

Rep: Reputation: 0
Quote:
Originally Posted by mahmoud View Post
Hi
i want to setup my ssl vhost and i have a bit of a problem
first i want to redirect the links to home page if its not secure
e.g
http://secure.myserver.com should go back to http://myserver.com
but
https://secure.myserver.com should stay on https://secure.myserver.com
and when on the https or secure link if they leave the pages that are secure they should be redirected back to http://myserver.com
i am using fedora 9 64bit
also i have alot of rewrites in there for the alias domains i have and i want it to affect all the


You can use HTTP_HOST , SERVER_PORT in rewrite conditions to do this.
for e.g.

RewriteCond %{HTTP_HOST} !^secure\.myserver\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) http://myserver.com/$1 [L,R]

This example should redirect all insecure url which math HTTP_HOST secure.myserver.com to http://myserver.com. you can add [OR] to add multiple conditions for HTTP_HOST.

You can use following rewrite rule to redirect all insecure URL's to secure without changing the HTTP_HOST(domain in URL) or REQUESTED_URL (files / URL requested)

RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
 
Old 11-11-2008, 07:52 AM   #3
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Original Poster
Rep: Reputation: 30
thanks thats working one more thing i what it to be that when you are on the link
https://myserevr.com goes to http://myserver.com
http://secure.myserver.com to goto http://myserver.com this is working
but when there is something like
http://secure.myserver.com/secure/page to be redirected to https://secure.myserver.com/secure/page
 
  


Reply

Tags
http, https, redirect


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
Apache Rewrite mahmoud Linux - Newbie 2 10-08-2008 08:11 AM
Apache rewrite rule help kinetik Linux - Software 1 11-05-2007 11:18 AM
apache rewrite help deesto Linux - Server 3 11-03-2006 02:07 PM
Need help with Apache rewrite kinetik Linux - General 6 05-19-2006 06:02 AM
Apache 2 Rewrite One Domain To Another thunder04 Linux - Software 10 04-19-2006 01:38 AM


All times are GMT -5. The time now is 05:14 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