Reputation: 345
I've benn trying to figure out what these two lines in Mod_Rewrite do and would appreciate some help. Thanks in advance.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php
Upvotes: 1
Views: 80
Reputation: 143886
They check if the requested URI is an existing file or a directory. The !
in front makes the condition "not", thus,, the request does NOT map to a file or directory.
See the -f
and -d
description in mod_rewrite
Don't all requests map to some file so that it can be loaded by the browser?
No. The request could be for something that doesn't exist and be rewritten. For example, http://en.wikipedia.org/wiki/something would mean the URI is /wiki/something
, which doesn't map to any physical file or directory. But internally, there is a rule that rewrites /wiki/something
to index.php?title=something
, and index.php
does exist.
Edit: for edited question
.php
to the end.!-f
and !-d
checks:
Upvotes: 4