LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 06-15-2003, 03:33 PM   #1
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
apache mod rewrite


i want to force ssl on certain pages:

like if the request is

http://thepage.com i want to rewrite it so that its https://thepage.com

what would the re-write rule look like for something like that....i dont know how to write the rules.

Last edited by Robert0380; 06-15-2003 at 03:34 PM.
 
Old 06-15-2003, 05:46 PM   #2
turnip
Member
 
Registered: Jul 2002
Posts: 143

Rep: Reputation: 15
Code:
RewriteCond %{HTTP_HOST} ^www.domain.net$
rewriteRule ^(.*) https://www.domain.net [L,R=301]
Should work, but it's untested. So let me know.

edit..


Put that in a .htaccess file btw
 
Old 06-15-2003, 08:09 PM   #3
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
no go, didnt kick out any errors, just didnt work. im reading up on regexes though.


edit.

just saw your edit on .htaccess, gotta try it again.

Last edited by Robert0380; 06-15-2003 at 08:10 PM.
 
Old 06-15-2003, 08:50 PM   #4
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
well, which .htaccess file?

the specific site is this (all permutations that i want to change)

http://robert.dynu.net/horde/imp
http://robert.dynu.net/horde
http://robert.dynu.net/horde/imp/login.php


actually i guess you could just say:

http://robert.dynu.net/horde <<<< anything that begins with that

i want to default exactly to :
Code:
https://robert.dynu.net/horde/imp/login.php
which .htaccess file would i put that in?

i want to force secure login to the email system. feel free to check out
the link, you can get horde and imp from http://horde.org

Last edited by Robert0380; 06-15-2003 at 08:51 PM.
 
Old 06-16-2003, 09:00 PM   #5
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
.just wanted to bump it up incase someone knew. last time i'll bump this though.
 
Old 07-31-2003, 04:42 PM   #6
Dayvid
LQ Newbie
 
Registered: Jul 2003
Location: Indianapolis, IN, USA
Distribution: Red Hat 8.0
Posts: 6

Rep: Reputation: 0
I did some googling and found this solution:

Code:
RewriteEngine on
RewriteCond   %{SERVER_PORT}  !^443$
RewriteRule   ^(.*)?$   https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Use that in your .htaccess file. That will rewrite everything in that directory to start with https:// but otherwise remain the same. Works perfectly when I try it, even with in subdirectories etc. without changes. Just put that by itself in your .htaccess file in the dir you want to protect by forcing SSL-only access and then test it.

[edit]I should give credit to this webpage: http://list.cobalt.com/pipermail/cob...er/033818.html for the solution above. The first example shown is what I used, but I modified it first to eliminate the RewriteBase command which I found was not needed (by process of elimination) and I also found that I could use the REQUEST_URI environment variable like I do in CGI scripts to insert whatever document path and name was requested, whereas the original example on that page had you changing the directory. I'd much rather have something that you just drop in and works rather than having to change it depending on what directory you happen to put it in! You may want to try the version on the linked page if mine doesn't work on your hosting provider, since your host may set different environment variables or set them differently than mine (which is http://www.bluevirtual.com).[/edit]
 
  


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
compile apache source rpm with mod rewrite robertngo Linux - Software 3 07-21-2005 03:44 AM
Need help with Apache rewrite rules?? latino Programming 0 12-24-2004 02:09 AM
Mod Rewrite Help carminejg3 Linux - Software 0 12-20-2004 05:19 PM
Apache rewrite question CrazyToon Linux - Software 3 06-17-2003 02:00 PM
Apache Rewrite Not Working mikeyt_333 Linux - General 1 05-20-2003 05:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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