Friday, 13 April 2007

Virtual file structure with mod_rewrite

It is cool to use virtual directory structure. You could keep all your code in several files and all the content in the DB.

Here is trick with mod_rewrite that you can put into .htaccess file on the root of your site. The urls, that are not physically exist on the server will be passed into index.html and you could parse them yourself.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?uri=/$1 [QSA,L]

No comments: