What does it mean - RewriteCond in Apache?

More specifically, this means, if not difficult, put it on the shelves, otherwise it is difficult for my brain to perceive this information.

 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d 

What does it mean? - If the requested directory or file exists in the URL, we refer to them directly in the documentation.

    1 answer 1

    These directives set the conditions for the following RewriteRule directive. Those. they themselves do not apply, after them there should be a directive that they affect

     RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php [L] 

    In particular !-f requires that the RewriteRule rule be applied only if a physically existing file does not match the request, and !-d - the query should not be used if a physically existing folder is requested. Thus, the rule in RewriteRule that follows these directives will apply only to virtual URLs for which there is no folder or file on the server disk.

    • Perfect. Much more to you, thank you! It turns out, I thus protect the real paths of the location of folders and files? - gilo1212
    • Yes exactly. - cheops
    • It is great! I was looking for that. - gilo1212
    • Podstazhite please, I made these rules in .htaccess, but I can still open the physical file. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f , why? I open the file where .htaccess lies, and it is in the root of the site - gilo1212
    • @ gilo1212 These directives do not prohibit access to files, they only remove them from the action of the RewriteRule rule. If you need to close access to them, it is probably better to create another question dedicated to this issue. - cheops