how do i redirect web trafic from port 80 to 443

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Mon Jan 5 18:17:52 UTC 2004


Am Mo, den 05.01.2004 schrieb Rodolfo J. Paiz um 08:09:
> 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,

to use some configuration you do not understand is never ever
recommended and even might be dangerous. It might lead to results which
are not wanted, even if it seems to resolve your problem. So you better
read the docs for mod_rewrite to know what the RewriteRule exactly does.
But take this advice in general.

Alexander


-- 
Alexander Dalloz | Enger, Germany
PGP key valid: made 13.07.1999
PGP fingerprint: 2307 88FD 2D41 038E 7416  14CD E197 6E88 ED69 5653





More information about the fedora-list mailing list