Why rewrite URLs? Check Wikipedia
Make sure AllowOverride is on for your directory, or put in httpd.conf
# Apache (.htaccess or httpd.conf)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
# basics
try_files $uri $uri/ /index.php?$args;
If you're trying to route requests for an app that is not in the document root, invoke klein's dispatch line like this:
<?php
define('APP_PATH', '/your/webapp');
dispatch(substr($_SERVER['REQUEST_URI'], strlen(APP_PATH)));
?>
Then in your nginx.conf
file, use:
location /your/webapp/ {
try_files $uri $uri/ /your/webapp/index.php?$args;
}
Don't do this.
# nginx
if (!-e $request_filename) {
rewrite . /index.php last;
}
See nginx pitfalls.
- http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
- http://wiki.nginx.org/HttpRewriteModule
- http://wiki.nginx.org/Pitfalls
- klein.php - simple, fast router for PHP
I've never actually used the PHP dev server, but per their docs it looks like basic URL rewriting is already built in: