mod_rewrite, redirecting https

This is a discussion on mod_rewrite, redirecting https within the Apache Web Server forums, part of the Web Server and Related Forums category; How would I go about redirecting 1 directory to https? For example, http://www.site.com/mail would redirect to ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-08-2003
Ryan
 
Posts: n/a
Default mod_rewrite, redirecting https

How would I go about redirecting 1 directory to https?

For example, http://www.site.com/mail would redirect to
https://www.site.com/mail

Ive tried numerous things with mod_rewrite but I cant get them to
work, maybe Im putting them in the wrong spot.
  #2 (permalink)  
Old 07-09-2003
davide@yahoo.com
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

Ryan <google@dearing.us> wrote:
> How would I go about redirecting 1 directory to https?


In your "normal" (non-HTTPS) part of the configuratin use
<Location /mail>
Redirect /mail https://.....
</Location>

It should work.

Davide
  #3 (permalink)  
Old 07-09-2003
Ryan
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

davide@yahoo.com wrote in message news:<beg9ga$4soob$5@ID-18487.news.dfncis.de>...
> Ryan <google@dearing.us> wrote:
> > How would I go about redirecting 1 directory to https?

>
> In your "normal" (non-HTTPS) part of the configuratin use
> <Location /mail>
> Redirect /mail https://.....
> </Location>
>
> It should work.
>
> Davide




I get a Redirection limit error. I had it redirect to https://site.com/mail
but that causes the above Redirect to happen again.... and again.... etc.

Any ideas?
  #4 (permalink)  
Old 07-09-2003
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

Ryan wrote:

> How would I go about redirecting 1 directory to https?
>
> For example, http://www.site.com/mail would redirect to
> https://www.site.com/mail
>
> Ive tried numerous things with mod_rewrite but I cant get them to
> work, maybe Im putting them in the wrong spot.


I'll assume that you had already tried this then:
RewriteRule http://www.site.com/mail https://www.site.com/mail

What about adding a condition checking the protocol? Now sure if this is
correct since I've never had to do this...

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PROTOCOL} ^(http|HTTP)$
RewriteRule ^mail(/.*)? https://www.site.com/mail$1

--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

  #5 (permalink)  
Old 07-09-2003
Ryan
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

Justin Koivisto <spam@koivi.com> wrote in message news:<a0WOa.36$m3.2636@news7.onvoy.net>...
> Ryan wrote:
>
> > How would I go about redirecting 1 directory to https?
> >
> > For example, http://www.site.com/mail would redirect to
> > https://www.site.com/mail
> >
> > Ive tried numerous things with mod_rewrite but I cant get them to
> > work, maybe Im putting them in the wrong spot.

>
> I'll assume that you had already tried this then:
> RewriteRule http://www.site.com/mail https://www.site.com/mail
>
> What about adding a condition checking the protocol? Now sure if this is
> correct since I've never had to do this...
>
> RewriteEngine On
> RewriteBase /
> RewriteCond %{SERVER_PROTOCOL} ^(http|HTTP)$
> RewriteRule ^mail(/.*)? https://www.site.com/mail$1



Ive tried both of these. It appears my rewrite rules dont work,
because I cant even make simple ones work....

Ill look more into it.
  #6 (permalink)  
Old 07-09-2003
D. Stussy
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

On Wed, 9 Jul 2003, Ryan wrote:
> davide@yahoo.com wrote in message news:<beg9ga$4soob$5@ID-18487.news.dfncis.de>...
> > Ryan <google@dearing.us> wrote:
> > > How would I go about redirecting 1 directory to https?

> >
> > In your "normal" (non-HTTPS) part of the configuratin use
> > <Location /mail>
> > Redirect /mail https://.....
> > </Location>
> >
> > It should work.
> >
> > Davide

>
> I get a Redirection limit error. I had it redirect to https://site.com/mail
> but that causes the above Redirect to happen again.... and again.... etc.
>
> Any ideas?


You didn't listen to what he said. He said to put this in the NON-HTTPS
configuration section, which probably means inside a <virtualhost> definition.
I bet that you put it directly into the main server.
  #7 (permalink)  
Old 07-10-2003
Rossz
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

google@dearing.us (Ryan) wrote in
news:8a734383.0307091305.35ee6b28@posting.google.c om:

> Justin Koivisto <spam@koivi.com> wrote in message
> news:<a0WOa.36$m3.2636@news7.onvoy.net>...
>> Ryan wrote:
>>
>> > How would I go about redirecting 1 directory to https?
>> >
>> > For example, http://www.site.com/mail would redirect to
>> > https://www.site.com/mail
>> >
>> > Ive tried numerous things with mod_rewrite but I cant get them to
>> > work, maybe Im putting them in the wrong spot.

>>
>> I'll assume that you had already tried this then:
>> RewriteRule http://www.site.com/mail https://www.site.com/mail
>>
>> What about adding a condition checking the protocol? Now sure if this
>> is correct since I've never had to do this...
>>
>> RewriteEngine On
>> RewriteBase /
>> RewriteCond %{SERVER_PROTOCOL} ^(http|HTTP)$
>> RewriteRule ^mail(/.*)? https://www.site.com/mail$1

>
>
> Ive tried both of these. It appears my rewrite rules dont work,
> because I cant even make simple ones work....


Try this:
RewriteCond %{SERVER_PROTOCOL} ^http$ [NC]
RewriteRule ^mail(/.*)? https://www.site.com/mail$1 [R,L]

Note the flags at the ends of the lines. If that doesn't work, try this:

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/mail/(.*)$ https:/www.site.com/mail/$1 [R,L]

--
Rossz

Remove 'NOSPAM' from my email address to reply directly
  #8 (permalink)  
Old 07-10-2003
Ryan
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

>
> Try this:
> RewriteCond %{SERVER_PROTOCOL} ^http$ [NC]
> RewriteRule ^mail(/.*)? https://www.site.com/mail$1 [R,L]
>
> Note the flags at the ends of the lines. If that doesn't work, try this:
>
> RewriteCond %{SERVER_PORT} ^80$
> RewriteRule ^/mail/(.*)$ https:/www.site.com/mail/$1 [R,L]



I got it working. Stupid me, I needed to add RewriteOptions inherit in
each of the virtual hosts...... yea i know, let the flaming begin.
haha.

thanks for the help!
  #9 (permalink)  
Old 07-11-2003
Rossz
 
Posts: n/a
Default Re: mod_rewrite, redirecting https

google@dearing.us (Ryan) wrote in
news:8a734383.0307100920.7f087dfd@posting.google.c om:

> yea i know, let the flaming begin.
> haha.


Naw, I remember making the same exact mistake, "but it should work you
stupid piece of s***!"


--
Rossz

Remove 'NOSPAM' from my email address to reply directly
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



All times are GMT +1. The time now is 09:18 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0