Hi, I’ve been using Certbot to create and renew SSL certificates on my server successfully for all websites, except for one in which the URL is rewritten to make it “pretty.” So instead of mydomain.com?page=viewer&edit=1299
it will display in the browser as mydomain.com/viewer/1299
.
The problem is that when I try to set up an LE certificate for this domain using this command:
certbot certonly --webroot -d mydomain.com -w /home/mysite/www
Certbot gives me the following error:
Failed authorization procedure.
mydomain.com
(http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response fromhttp://mydomain.com/.well-known/acme-challenge/HD7hKQ8sUNBjPbmLna6X_zCt_Kzzs66mTEdAX1UBqjo
I have a CentOS 7 server running Apache 2.4. These are the rewrite rules for this website located in the .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !mydomain.com [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
RewriteRule /*\.(css|txt|js|gif|png|pdf|ico|jpe?g)$ - [NC,L]
RewriteRule "^(.*)$" "index.php?_url=$1" [QSA,L]
I found something online which suggested allowing the .well-known folder to be seen as-is and stop rewriting if that folder is being accessed, so I added a new RewriteRule line to my .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !mydomain.com [NC]
RewriteRule ^\.well-known\/acme-challenge\/ - [L]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
RewriteRule /*\.(css|txt|js|gif|png|pdf|ico|jpe?g)$ - [NC,L]
RewriteRule "^(.*)$" "index.php?_url=$1" [QSA,L]
However, adding RewriteRule ^\.well-known\/acme-challenge\/ - [L]
doesn’t work, it produces a “too many redirects” error in the browser and the page fails to load.
I’m not really terribly familiar with Rewrite rules and was wondering if anyone else has already figured out how to allow Certbot access to .well-known
on sites that use re-writing to make the URLs pretty, and how I can modify my own to work so renewals will work without having to manually create and renew certificates for this and other sites that use the same type of URL re-writing.
Thanks!