[unclug] Redirect 80 ---> 443 with Apache?

John W. Sopko Jr. sopko at cs.unc.edu
Fri Feb 20 10:52:32 EST 2004

Success! John's question made me think!

I am using virtual hosts, (if you use virtual hosts you must have
a virtual host for the primary host or it defaults to the first
virtual host it finds). I put the mod_rewrite in the virtual host 
section and it works! Now I can sleep this weekend. Guess this makes
sense so the mod_rewrite is not global, dahhhh!

Thanks for all the help!


# define the main server, must be defined!
     ServerName lark.cs.unc.edu
     DocumentRoot "/afs/cs.unc.edu/common/doc/www"
     RewriteEngine       on
     RewriteCond %{SERVER_PORT}  !^443$
     RewriteRule ^/(.*)          https://%{SERVER_NAME}/$1 [NC,R,L]

Check it go to:

http://lark.cs.unc.edu and you will get re-directed to https...

John Reuning wrote:

> What do you have set in the ServerName directive line?
> And have you tried configuring a vhost block for lark.cs.unc.edu and
> putting the rewrite rule there?
> On Fri, 2004-02-20 at 10:35, John W. Sopko Jr. wrote:
>>Nothing in the error_log/access_log, looks like it is just ignoring the
>>rewrite match expression.
> _______________________________________________
> unclug mailing list
> unclug at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/unclug

John W. Sopko Jr.               University of North Carolina
email: sopko AT cs.unc.edu      Computer Science Dept., CB 3175
Phone: 919-962-1844             Sitterson Hall; Room 044
Fax:   919-962-1799             Chapel Hill, NC 27599-3175

More information about the unclug mailing list