Contact Karthik Viswanathan

x Cancel
posted 3 years ago

Global PHP Handler with .htaccess

                RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?request=$1 [L,QSA]                
Raw

This .htaccess snippet is widely-used to rewrite requests so they are handled by one, global PHP file (in this case, index.php). Not only does it help standardize the processing of requests, but it does so in a succinct, effective manner.

Note that the request is available in $_GET[ 'request' ] variable.