Created
April 8, 2011 17:32
Revisions
-
jamesvl revised this gist
Apr 14, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Make sure [AllowOverride](http://httpd.apache.org/docs/2.0/mod/core.html#allowov 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))); ?> -
jamesvl revised this gist
Apr 14, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,8 @@ Make sure [AllowOverride](http://httpd.apache.org/docs/2.0/mod/core.html#allowov 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', '/webapps/criminal/crim_daily_calendar'); dispatch(substr($_SERVER['REQUEST_URI'], strlen(APP_PATH))); ?> Then in your `nginx.conf` file, use: -
jamesvl revised this gist
Apr 14, 2011 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ ## URL-rewriting for klein PHP router Why rewrite URLs? Check [Wikipedia](http://en.wikipedia.org/wiki/Rewrite_engine) ### Apache Make sure [AllowOverride](http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride) is on for your directory, or put in `httpd.conf` # Apache (.htaccess or httpd.conf) RewriteEngine On @@ -13,33 +13,35 @@ Make sure [AllowOverride](http://httpd.apache.org/docs/2.0/mod/core.html#allowov ### nginx # 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', '/webapps/criminal/crim_daily_calendar'); 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://wiki.nginx.org/Pitfalls). ## More Reading * http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html * http://wiki.nginx.org/HttpRewriteModule * http://wiki.nginx.org/Pitfalls * [klein.php](https://github.com/chriso/klein.php) - simple, fast router for PHP Note: This gist originally [here](https://gist.github.com/874000), from [chriso](https://github.com/chriso) -
jamesvl revised this gist
Apr 14, 2011 . 2 changed files with 45 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ ## URL-rewriting for klein PHP router Why rewrite URLs? Read this: http://en.wikipedia.org/wiki/Rewrite_engine ### Apache Make sure [AllowOverride](http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride) is on for the directory, or put in `httpd.conf` # Apache (.htaccess or httpd.conf) RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /index.php [L] ### nginx # basic version try_files $uri $uri/ /index.php?$args; If you're trying to route requests for an app that is *not* in the document root, you can do so. You have to invoke klein's dispatch line like this though: <?php define('APP_PATH', '/webapps/criminal/crim_daily_calendar'); dispatch(substr($_SERVER['REQUEST_URI'], strlen(APP_PATH))); ?> In your `nginx.conf` file, use: location /your/webapp/ { try_files $uri $uri/ /your/webapp/index.php?$args; } Don't do this. See [nginx pitfalls](http://wiki.nginx.org/Pitfalls). # nginx if (!-e $request_filename) { rewrite . /index.php last; } ## More Reading * http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html * http://wiki.nginx.org/HttpRewriteModule * http://wiki.nginx.org/Pitfalls * [klein.php](https://github.com/chriso/klein.php) - simple, fast router for PHP Note: This gist [originally here](https://gist.github.com/874000), from [chriso](https://github.com/chriso) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +0,0 @@ -
jamesvl revised this gist
Apr 14, 2011 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,10 @@ if (!-e $request_filename) { rewrite . /index.php last; } # basic version try_files $uri $uri/ /index.php?$args; # if running klein from a subdirectory location /your/webapp/ { try_files $uri $uri/ /your/webapp/index.php?$args; } -
jamesvl revised this gist
Apr 8, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ # Apache RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # nginx # bad - see http://wiki.nginx.org/Pitfalls -
jamesvl revised this gist
Apr 8, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ # Apache RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # nginx # bad - see http://wiki.nginx.org/Pitfalls -
jamesvl revised this gist
Apr 8, 2011 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,14 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # nginx # bad - see http://wiki.nginx.org/Pitfalls if (!-e $request_filename) { rewrite . /index.php last; } # better try_files $uri $uri/ /index.php; # better still, for our purposes (remove '/' if in a location block?) try_files $uri /index.php; -
jamesvl revised this gist
Apr 8, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # NGINX if (!-e $request_filename) { -
jamesvl revised this gist
Apr 8, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # Apache RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # NGINX -
chriso revised this gist
Apr 7, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ # Apache RewriteEngine On RewriteCond %{REQUEST_FILENAME}!-f RewriteCond %{REQUEST_FILENAME}!-d RewriteRule . /index.php [L] # NGINX if (!-e $request_filename) { rewrite . /index.php last; } -
chriso revised this gist
Apr 7, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,10 @@ /* Apache */ RewriteEngine On RewriteCond %{REQUEST_FILENAME}!-f RewriteCond %{REQUEST_FILENAME}!-d RewriteRule . /index.php [L] /* NGINX */ if (!-e $request_filename) { rewrite . /index.php last; } -
chriso created this gist
Mar 17, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ /* Apache */ RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}!-f RewriteCond %{REQUEST_FILENAME}!-d RewriteRule . /index.php [L] /* NGINX */ if (!-e $request_filename) { rewrite ^(.+)$ /index.php last; }