Using a modified RewriteCond to check for a file in multiple places

I want to use mod-rewrite to check a file in two different places: at the requested URL and at the requested URL in the โ€œpublicโ€ directory.

Here is what I still have:

RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -D
RewriteCond% {DOCUMENT_ROOT} / public / $ 0! -F #this line isn't working
RewriteRule ^ (. *) $ Index.php? $ 1 [L]

It can correctly determine if there is a file, but it does not correctly determine if the file is in /public/supplied/file/path/file.extension. How can I check this?

+3
source share
1 answer

, , public/ . .htaccess. , .htaccess, .htaccess ?

. -F , .htaccess. :

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond public/$0 !-F
RewriteRule ^(.*)$ index.php?$1 [L,B]

, -F , -F, stat . B, .

+4

Source: https://habr.com/ru/post/1747661/


All Articles