gaby
gaby

Reputation: 51

Regex in If condition in apache configuration (let's encrypt configuration for renewal certificate)

I am trying to make the certificate renewal work. I guess with the new version, let's encrypt will look on http://[mondomain]/.well-known/acme-challenge/....

So, in my apache configurations, on my virtual host of port 80, I wanted to put a regex which when the .well-known exists in the URI, I do not redirect my virtualhost https so that let's encrypt can make your challenge (I tested and my certificate is well renewed when I deleted all redirects).

I specify that the directory /var/www/html/.well-known/acme-challenge exists on the apache server and that my DNS is with DNS provider.

I don't understand why my regex is not working.

Can you help me please ?

Here is the apache configuration.

<VirtualHost *:80>

    ServerName [Domain]
    ServerAlias [DomainWWW]
    DocumentRoot /var/www/html
    #Alias "/.well-known/acme-challenge/" "/var/www/html/.well-known/acme-challenge/
    #RewriteEngine on
    #RewriteCond %{HTTPS} !on
    #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}



    <If "%{REQUEST_URI} !~ m#\.well-known\/acme-challenge\/.*m#">
       RewriteEngine on
       RewriteCond %{HTTPS} on
       RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </If>



</VirtualHost>

Thank you in advance.

Upvotes: 0

Views: 365

Answers (1)

gaby
gaby

Reputation: 51

The regex was OK . I was able to renew certificate. That's good now ! :)

Upvotes: 0

Related Questions