I want to use one index.php file for all requests, except for files that exist eg. images, CSS and JS.
Also I want to force trailing slash on all requests.
Also I want to have one folder with system files that should not be accessible. But I don't want any one to see that this folder or these files exist.
Also I want all this to be as fast as possible.
I figured that I could use this htaccess:
RewriteEngine On
# Force trailing slash on the end
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
# Handle all request from one index.php file
ErrorDocument 404 /index.php
# Prevent system folder from being accessed
RedirectMatch 404 ^/system/?$
In index.php I will decide if page exist or not and set response code accordingly.
I'm no pro, but it seems to work. But I wonder if ErrorDocument 404 /index.php will slowing anything down, eg. affecting how the server cache the request in the RAM memory?