rewriterule 301, redirect works for 80 ignored for 443
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Web Servers on Unix and Linux > rewriterule 301, redirect works for 80 ignored for 443




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    rewriterule 301, redirect works for 80 ignored for 443  
David Mathog


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-06-07 12:17 AM

I manage a web site which over the years has picked up a lot
of DNS alias names.  I'm trying to send 301 redirects to any client
that uses one of the older names.  This web server uses both
ports 80 and 443.  This redirect does exactly what I want for
port 80, but nothing happens for port 443, whatever the original
(alias) name used was, that stays in the browser and there is
no redirect.  This is I believe the relevant part of the httpd.conf
file:

ServerName theserver.theschool.edu
UseCanonicalName On


RewriteEngine        on

RewriteCond %{HTTPS} !=off
RewriteCond %{HTTP_HOST} !^theserver\.theschool\.edu [NC]
RewriteRule ^(.*) https://theserver.theschool.edu$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^theserver\.theschool\.edu [NC]
RewriteRule ^(.*) http://theserver.theschool.edu$1 [R=301,L]

(Note it uses "theserver.theschool.edu$1" instead  of
"theserver.theschool.edu/$1", as in every example I found on the net,
because the latter form always puts two slashes after the
server's name in the URL.)

Apache 2.054 server running on Solaris 8, tested with Seamonkey.

Thanks,

David Mathog





[ Post a follow-up to this message ]



    Re: rewriterule 301, redirect works for 80 ignored for 443  
David Mathog


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-06-07 12:17 AM

David Mathog wrote:

>    RewriteCond %{HTTPS} !=off
>    RewriteCond %{HTTP_HOST} !^theserver\.theschool\.edu [NC]
>    RewriteRule ^(.*) https://theserver.theschool.edu$1 [R=301,L]

Ok, I figured it out.  These lines needed to be moved out of httpd.conf
and into the ssl.conf file, after

<VirtualHost _default_:443>

Once in there and the server was restarted everything worked as desired.
Also the HTTPS ReweriteCond can be omitted,  since at 443 HTTPS is
always on.

Regards,

David Mathog





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:43 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register