rewrite rule for http URL -> https URL on specified directory

rewrite rule for http URL -> https URL on specified directory

Post by David Math » Sun, 13 May 2001 08:08:35



We have some directories which should only be accessed via https.  The
mod_ssl example in the "how to" section describes:

#   Force clients from the Internet to use HTTPS
      Rewri*gine        on
      RewriteCond          %{HTTPS} !=on
      RewriteRule          .* - [F]

That prevents http access, but does not redirect to an https URL.  So which
RewriteRule(s) does one use to tell the rewrite engine to do:

   http://machine/somepath/* -> https://machine/somepath/*

???

Thanks,

David Mathog

Manager, sequence analysis facility, biology division, Caltech

 
 
 

rewrite rule for http URL -> https URL on specified directory

Post by Joshua Sliv » Sun, 13 May 2001 10:40:23



> We have some directories which should only be accessed via https.  The
> mod_ssl example in the "how to" section describes:
> #   Force clients from the Internet to use HTTPS
>       Rewri*gine        on
>       RewriteCond          %{HTTPS} !=on
>       RewriteRule          .* - [F]
> That prevents http access, but does not redirect to an https URL.  So which
> RewriteRule(s) does one use to tell the rewrite engine to do:
>    http://machine/somepath/* -> https://machine/somepath/*

You should probably read the mod_rewrite documentation before you
try to use this module.

But, anyway, here is my best (untested) guess:

RewriteRule ^/somepath/(.*) https://machine/somepath/$1 [R]

--
Joshua Slive

http://www.veryComputer.com/

 
 
 

rewrite rule for http URL -> https URL on specified directory

Post by David Math » Tue, 15 May 2001 23:36:53




>> We have some directories which should only be accessed via https.  The
>> mod_ssl example in the "how to" section describes:

>> #   Force clients from the Internet to use HTTPS
>>       Rewri*gine        on
>>       RewriteCond          %{HTTPS} !=on
>>       RewriteRule          .* - [F]

>> That prevents http access, but does not redirect to an https URL.  So which
>> RewriteRule(s) does one use to tell the rewrite engine to do:

>>    http://machine/somepath/* -> https://machine/somepath/*

>You should probably read the mod_rewrite documentation before you
>try to use this module.

>But, anyway, here is my best (untested) guess:

>RewriteRule ^/somepath/(.*) https://machine/somepath/$1 [R]

But won't that also redirect https://somepath/ back to itself?

Thanks,

David Mathog

Manager, sequence analysis facility, biology division, Caltech

 
 
 

rewrite rule for http URL -> https URL on specified directory

Post by adam » Tue, 15 May 2001 23:47:44





> >> We have some directories which should only be accessed via https.  The
> >> mod_ssl example in the "how to" section describes:

> >> #   Force clients from the Internet to use HTTPS
> >>       Rewri*gine        on
> >>       RewriteCond          %{HTTPS} !=on
> >>       RewriteRule          .* - [F]

> >> That prevents http access, but does not redirect to an https URL.  So which
> >> RewriteRule(s) does one use to tell the rewrite engine to do:

> >>    http://machine/somepath/* -> https://machine/somepath/*

> >RewriteRule ^/somepath/(.*) https://machine/somepath/$1 [R]

> But won't that also redirect https://somepath/ back to itself?

I believe Joshua is implying you should replace your RewriteRule with
his, leaving the Rewri*gine and RewriteCond's as they are.

--
-adam                 | "Be liberal in what you accept, and
Systems Administrator |  conservative in what you send"
Indiana University    |      -Jon Postel
Bloomington, Indiana  |