I'm currently redirecting everything to app/index.html because I have a client-side single page app. However, I want to skip redirecting for actual files and directories. I've gotten this far. However, when I add in the RewriteCond for skipping files that are directories, it counts the document root as well. This causes a visit to a document root such as hitting http://localhost:8080
to just list my dir contents. How would I get this to not apply to the document root or any other better way? P.S. I'm also skipping the /api dir.
Here is what I have so far:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/api
RewriteRule ^(.*)$ /app/index.html/$1 [NC]
So essentially I guess what I'm asking is: How can I skip directories except for the document root directory?
Solution
With help from the answer that Krist van Besien
gave I was able to come to a solution.
# not a directory
RewriteCond %{REQUEST_FILENAME} !-d [OR]
# or if it is the document root
RewriteCond %{REQUEST_URI} ^/$
# not a file
RewriteCond %{REQUEST_FILENAME} !-f
# not /api
RewriteCond %{REQUEST_URI} !^/api$
RewriteRule ^(.*)$ portal/index.html/$1 [NC]