Route Non-Existing Files Through Index.php [htaccess]

As long as a file or directory doesn’t actually exist, this will route all URL requests through a specified file (in this case, index.php).

Commonly used by frameworks and CMS’s (like CodeIgniter or WordPress).

In .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]

Leave a Reply

Your email address will not be published. Required fields are marked *