From: Rich Bowen Date: Mon, 11 May 2026 19:31:10 +0000 (+0000) Subject: Rewrite guide: deduplicate HTTPS redirect recipe X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a53870b71bdb812e6d0c01dd07e5e32df83d111e;p=thirdparty%2Fapache%2Fhttpd.git Rewrite guide: deduplicate HTTPS redirect recipe avoid.xml had a full VirtualHost example for HTTP-to-HTTPS that was identical to remapping.xml's version. Replace with a brief paragraph and cross-reference to remapping.html#https-redirect, which covers both the Redirect and .htaccess mod_rewrite approaches. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934120 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/TODO.md b/docs/manual/rewrite/TODO.md index d897d585bf..d89fbec441 100644 --- a/docs/manual/rewrite/TODO.md +++ b/docs/manual/rewrite/TODO.md @@ -32,7 +32,7 @@ result in one file "owning" the content and others cross-referencing it. "canonicalhost" and "www-resolve" cover the same concept. → Merge "www-resolve" into "canonicalhost". -- [ ] **HTTPS redirect** covered in both avoid.xml and remapping.xml. +- [x] **HTTPS redirect** covered in both avoid.xml and remapping.xml. → remapping.xml owns the recipe; avoid.xml references it. ## LOW Priority diff --git a/docs/manual/rewrite/avoid.xml b/docs/manual/rewrite/avoid.xml index 39b2e132a9..f2ce351fb1 100644 --- a/docs/manual/rewrite/avoid.xml +++ b/docs/manual/rewrite/avoid.xml @@ -97,32 +97,13 @@ Redirect "/one/" "http://one.example.com/" Canonical Hostnames recipe.

-

To redirect http URLs to https, do the -following:

- - -<VirtualHost *:80> - ServerName www.example.com - Redirect "/" "https://www.example.com/" -</VirtualHost> - -<VirtualHost *:443> - ServerName www.example.com - # ... SSL configuration goes here -</VirtualHost> - - -

The use of RewriteRule to perform this task may be -appropriate if there are other RewriteRule directives in -the same scope. This is because, when there are Redirect -and RewriteRule directives in the same scope, the -RewriteRule directives will run first, regardless of the -order of appearance in the configuration file.

- -

In the case of the http-to-https redirection, the use of -RewriteRule would be appropriate if you don't have access -to the main server configuration file, and are obliged to perform this -task in a .htaccess file instead.

+

To redirect http URLs to https, a +Redirect in a dedicated +HTTP virtual host is the cleanest approach. See the +Forcing HTTPS recipe for +the recommended configuration and the +mod_rewrite alternative for .htaccess +use.