Home How to fix htaccess RewriteRule back reference to RewriteCond? Fix for CPANEL AutoSSL Let’s Encrypt
Reply: 0

How to fix htaccess RewriteRule back reference to RewriteCond? Fix for CPANEL AutoSSL Let’s Encrypt

user793
1#
user793 Published in June 19, 2018, 6:27 pm

CPANEL with AutoSSL (Let’s Encrypt) add automatic RewriteCond to htaccess because .well-known folder and keep updating htaccess file every X minutes, so you can't delete the "well-know" lines. But with this approach they break RewriteRule back reference to RewriteCond.

# www to non-www generic
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This example above don't work as spectated because %1 references last RewriteCond, and not the first where we filter the host with regexp.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.393673 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO