How to exclude .well-known from redirection for Letsencrypt with .htaccess in Laravel?

I am trying to get Let’s Encrypt SSL but the problem is my Laravel script route all the links. All folders in the root directory are redirected to the public folder with the apache .htaccess rule.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]

Here is the configuration from my .htaccess file.

I figure out that when I try to generate SSL I get this error

Detail: Invalid response from

And when I try to visit the link I get a Laravel 404 error. So Laravel is redirecting the well-known folder as well. So can anyone tell me, how I exclude the redirection and verify the Letsencrypt SSL?

Well, this is very simple, if you look at your .htaccess configuration, you will find the solution there.

RewriteCond %{REQUEST_URI} !^public

With this line, you are preventing the public folder from being redirected. You can do the same for .well-known folder. Try this line below.

RewriteCond %{REQUEST_URI} !^/\.well-known

This should solve your problem and you should be able to generate SSL with Let’s Encrypt.