Rewrite for RESTful URLs in Apache and Nginx
August 24, 2011 by admin · Leave a Comment
Here is a excellent tutorial show you how to Rewrite for RESTful URLs in Apache and Nginx:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L]The two RewriteCond statements check to make sure that there is no filename or directory that matches a user’s request. If not, then it rewrites to the index.php page. The [L] means to stop executing rewrites at that line.
Now for Nginx and it’s Rewrite module:if (!-e $request_filename) { rewrite ^(.*)$ index.php last; }