Rewriting https to http

Jonathan Dance jd at
Fri Jan 12 14:57:13 MSK 2007

> The order of locaiton processing is described here:

As previously mentioned there, the documentation for this (very
important) command is quite hard to understand and was in need of
attention. So, after much re-reading and using Google translate on the
Russian docs, I think I understood it and completely rewrote that
section. I would appreciate it if Igor and the other nginx team
members could review it to make sure it is correct.

> RewriteCond %{SERVER_PORT} ^443$
> RewriteCond $1 !^(securedir|2ndsecuredir|3rdsecuredir)/ [NC,OR]
> RewriteCond $1 !\.(css|gif|jpe?g|bmp|js|inc)$ [NC]
> RewriteRule ^/(.*)$1 [R=301,L]

Igor's example will work but I might recommend folding it into a
single regex so you only have a single location block to configure,

location ~* "^(securedir|2ndsecuredir|3rdsecuredir)|\.(css|gif|jpe?g|bmp|js|inc)$"

This is slower than using the non-regex versions like Igor did but for
me the convenience of a shorter configuration file outweighs the
performance hit of a regex call... besides, the regex was going to be
called anyway unless you use ^~ (see the docs :) ).

Best regards,

More information about the nginx mailing list