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

Jeff Bollinger jeff01 at email.unc.edu
Fri Feb 6 11:45:10 EST 2004


Jeff Bollinger wrote:
> I am setting up an Apache 2.0.48 webserver and when anyone makes a 
> request to http://sitename, I want it to automatically redirect to 
> https://sitename.  Do I have to use mod_rewrite for this, or can I just 
> alter some other directive (Listen??)
> 
> Thanks!
> Jeff


Thanks for all the replies.  For posterity, here's how you redirect all 
connections to an Apache server to SSL (https):


make sure mod_rewrite is loaded:

LoadModule rewrite_module modules/mod_rewrite.so

and add this to your httpd.conf file:

RewriteEngine  on
RewriteCond    %{SERVER_PORT}  !^443$
RewriteRule    ^/(.*)          https://%{SERVER_NAME}/$1 [L,R,NC]

Jeff




More information about the unclug mailing list