Dave
Dave

Reputation: 822

Apache Rewrite !-f !-d But Allow File In Dotted Folder

I have a web site that redirects all nonfolders and files to an index.php script, like so:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q={$1} [L,QSA]

But, I am using letsencrypt, and would like to be able to access a file directly to confirm the SSL cert. The file path would be:

http://example.org/.well-known/acme-challenge/ReGasdfq8is_ogwLaQzd42QH49qZJwgasdfVEnoOJSk

When I try to access that path, it is being redirected to the index.php script and not displaying the contents of the ReGasdfq8is_ogwLaQzd42QH49qZJwgasdfVEnoOJSk file.

Is that because the .well-known folder is dotted? Can I allow access to the dotted folder?

Upvotes: 0

Views: 393

Answers (1)

Matt in Washington
Matt in Washington

Reputation: 197

Something like this

RewriteEngine on
RewriteCond $1 !^(/.well-known)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q={$1} [L,QSA]

(Edited by Dave to add slash and remove space - to reflect working solution)

Upvotes: 1

Related Questions