how do i redirect web trafic from port 80 to 443

Rodolfo J. Paiz rpaiz at simpaticus.com
Mon Jan 5 07:09:35 UTC 2004


At 00:55 1/5/2004, you wrote:
>Instead of a service restart, maybe you need to reboot the machine entirely.

That's really never necessary unless you've upgraded the kernel. There is 
nothing you can do to Apache, AFAIK, that will not take effect on a 
"service httpd restart". So likely there is some problem with those rules.

After a long search and lots of trial and error, I managed to get the 
following to work reliably for me:

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

Don't ask me what it does or why it works. All I know is that, if the 
server receives a request for any page on that site which does not come in 
on port 443, it will rewrite the address (for the exact same page) to start 
with HTTPS and redirect to that page. So no matter what page you request, 
you will be served that page via the secure server.

Works like a charm, has done so for several months now. No errors or 
problems reported so far.


-- 
Rodolfo J. Paiz
rpaiz at simpaticus.com
http://www.simpaticus.com





More information about the fedora-list mailing list