25-10-2008

mod_rewrite Single entry point for dynamic calls

Redirect all calls to dynamic content to index.php. Requests for static files are simply served as static files

Save the following in a .htaccess and save in root:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
  • # '-d' (is directory) Treats the TestString as a pathname and tests if it exists and is a directory.
  • # '-f' (is regular file) Treats the TestString as a pathname and tests if it exists and is a regular file.
  • # '-s' (is regular file with size) # Treats the TestString as a pathname and tests if it exists and is a regular file with size greater than zero.
  • # '-l' (is symbolic link) Treats the TestString as a pathname and tests if it exists and is a symbolic link.

Comments:

Your comment:

»

 

[x]