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

Joe Morris morris at unc.edu
Fri Feb 20 10:13:03 EST 2004

On Fri, 20 Feb 2004, John W. Sopko Jr. wrote:

| The NC is for No Case (case insensitve match), the R is required if
| you redirect back to your own site using a http:// URL, (very cryptic, I
| had to look this up, then again mod_rewrite is pretty cryptic), the L
| is to tell mod_rewrite this is the last rule to process. The
| rule:
| RewriteCond     %{SERVER_PORT}  !^443$
| RewriteRule     ^/(.*)          https://%{SERVER_NAME}/$1 [NC,R,L]
| should not cause a loop, if coming in on port 80 it should
| re-direct to 443 and coming in on 443 will make the match
| false and skip the RewriteRule.

Do you have the following as well?

  RewriteEngine On

What is SERVER_NAME set to?  May want to just force that to the web site
name to avoid any confusion there.  Don't have to worry about that NC
option as there as you are not comparing any such strings.

Joe Morris, Web Systems Manager
Academic Technology and Networks
The University of North Carolina at Chapel Hill

More information about the unclug mailing list