From a256b3681092703626bc0bbdabf6d86de4ee5441 Mon Sep 17 00:00:00 2001 From: Fabrice Luraine Date: Thu, 5 Aug 2010 09:47:12 +0200 Subject: [PATCH] Improving htaccess rules to support clean urls with query string like http://localhost/api/orders.json?foo=1&bar=2 (will be rewritten in http://localhost/api/index.php?uri=orders.json&foo=1&bar=2) --- README.mkd | 5 ++++- examples/urlrewrite/htaccess.conf | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 45e19c1..a5ec022 100644 --- a/README.mkd +++ b/README.mkd @@ -163,7 +163,10 @@ With a `.htaccess` in your app folder # test string is a valid directory RewriteCond %{SCRIPT_FILENAME} !-d - RewriteRule ^(.*)$ index.php?/$1 [NC,L] + RewriteRule ^(.*)$ index.php?uri=/$1 [NC,L,QSA] + # with QSA flag (query string append), + # forces the rewrite engine to append a query string part of the + # substitution string to the existing string, instead of replacing it. And setting explicitly the `option('base_uri')` in your configure() function: diff --git a/examples/urlrewrite/htaccess.conf b/examples/urlrewrite/htaccess.conf index e69de29..6843a74 100644 --- a/examples/urlrewrite/htaccess.conf +++ b/examples/urlrewrite/htaccess.conf @@ -0,0 +1,16 @@ + + Options +FollowSymlinks + Options +Indexes + RewriteEngine on + # RewriteBase /my_app/ # if your app is in a subfolder + + # test string is a valid files + RewriteCond %{SCRIPT_FILENAME} !-f + # test string is a valid directory + RewriteCond %{SCRIPT_FILENAME} !-d + + RewriteRule ^(.*)$ index.php?uri=/$1 [NC,L,QSA] + # with QSA flag (query string append), + # forces the rewrite engine to append a query string part of the + # substitution string to the existing string, instead of replacing it. + \ No newline at end of file