I spent about 20 minutes wrapping my head around this, and finally came to a solution but did not know why it worked. The important lines (as it relates to this question) in the apache configuration file looked like this:RewriteEngine OnRewriteCond %{ENV:REDIRECT_STATUS} 200RewriteRule ^ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^$ /abc [L]When I tried accessing http://example.com, the last rewriterule is skipped but what I do not understand is how is nothing a directory?Based on the last three items from the way I see it, I'm checking to see if I'm requesting a file or a folder, and if not, then redirect nothing (aka the default page) to /abc.It turns out here that RewriteCond %{REQUEST_FILENAME} !-d returns false because when I remove it and try again using the configuration shown below:RewriteEngine OnRewriteCond %{ENV:REDIRECT_STATUS} 200RewriteRule ^ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^$ /abc [L]the redirection then works.Is there a reason as to why nothing counts as a directory?I don't want to fall into any more illogical traps like this as I update my website.
Is a blank really a directory when dealing with mod-rewrite?
apache;mod rewrite;url rewriting;subdirectory
Becuase you are not checking that nothing is a directory, you are checking whether REQUEST_FILENAME is a directory (or not in this case).Whilst the URL-path, that matches against the RewriteRule pattern, is nothing (after the directory-prefix is removed), the REQUEST_FILENAME (which contains the absolute filesystem path that the request maps to, ie. not a URL) will contain something like /home/username/public_html/ (depending on your config). This is a directory on the local filesystem, so the above RewriteCond evaluates to false.