Web Servers on Unix and Linux - rewriterule 301, redirect works for 80 ignored for 443

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > March 2007 > rewriterule 301, redirect works for 80 ignored for 443





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

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

2007-03-05, 7:17 pm

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
David Mathog

2007-03-05, 7:17 pm

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
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com