home

Quickies, by Andrea Olivato

text

Htaccess redirects non-static non-existing files to index.php

This is the fastest way to achieve a good url rewriting in Php, redirecting every non-existing file or directory to the index.php. The following htaccess also make chekcs to exclude automatically images,js,css from being redirected

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !^.*\.png [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.css [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.jpg [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [nc]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

3 years ago

May 16, 2009
Comments (View)
blog comments powered by Disqus