From: Rich Bowen Date: Wed, 20 May 2026 21:07:10 +0000 (+0000) Subject: rewrite: add ACME challenge exemption recipe alongside HTTPS redirect X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f9ac0513f30ce6bd36de9742c578f39d1da73ff;p=thirdparty%2Fapache%2Fhttpd.git rewrite: add ACME challenge exemption recipe alongside HTTPS redirect git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934454 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/TODO.md b/docs/manual/rewrite/TODO.md index d914dd67f0..10361e546d 100644 --- a/docs/manual/rewrite/TODO.md +++ b/docs/manual/rewrite/TODO.md @@ -1,7 +1,5 @@ # Rewrite Docs — Suggested addition -- [ ] **Let's Encrypt ACME challenge exemption** — one-liner recipe, - universally needed alongside HTTPS redirect. Add to remapping.xml. - - [ ] **flags** - Add examples to flags that lack them. (See bz #70043) + diff --git a/docs/manual/rewrite/remapping.xml b/docs/manual/rewrite/remapping.xml index c9c7694c04..b1be63c187 100644 --- a/docs/manual/rewrite/remapping.xml +++ b/docs/manual/rewrite/remapping.xml @@ -166,6 +166,70 @@ RewriteRule "^(.*)" "https://%{SERVER_NAME}$1" [R=301,L] +
+ + Exempting ACME challenge requests from HTTPS redirect + +
+
Description:
+ +
+

You have forced all traffic to HTTPS (as above), but your + ACME client (Let's Encrypt, Certbot, etc.) needs plain HTTP + access to /.well-known/acme-challenge/ to complete + domain validation.

+
+ +
Solution:
+ +
+

Place an exception before your HTTPS redirect + rule:

+ + +RewriteEngine On +RewriteRule "^/\.well-known/acme-challenge/" - [L] +RewriteCond "%{HTTPS}" !=on +RewriteRule "^(.*)" "https://%{SERVER_NAME}$1" [R=301,L] + +
+ +
Discussion:
+ +
+

The dash (-) substitution means "do not rewrite." + Combined with [L], it stops rule processing for any + request matching the ACME challenge path, allowing it to be + served over plain HTTP. All other requests continue to the + next rule and are redirected to HTTPS as usual.

+ +

If you are using the Redirect approach in a dedicated + port-80 VirtualHost, use an + Alias and + RedirectMatch + instead:

+ + +<VirtualHost *:80> + ServerName www.example.com + + # Allow ACME challenges over HTTP + Alias "/.well-known/acme-challenge/" "/var/www/acme/.well-known/acme-challenge/" + <Directory "/var/www/acme/.well-known/acme-challenge"> + Require all granted + </Directory> + + # Everything else goes to HTTPS + RedirectMatch permanent "^/(?!\.well-known/acme-challenge/)" "https://www.example.com/$0" +</VirtualHost> + + +
+
+ +
+
Trailing Slash Normalization