Skip to content

Commit

Permalink
Improving htaccess rules to support clean urls with query string like
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Fabrice Luraine committed Aug 5, 2010
1 parent 2bc8f84 commit a256b36
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.mkd
Expand Up @@ -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.
</IfModule>

And setting explicitly the `option('base_uri')` in your configure() function:
Expand Down
16 changes: 16 additions & 0 deletions examples/urlrewrite/htaccess.conf
@@ -0,0 +1,16 @@
<IfModule mod_rewrite.c>
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.
</IfModule>

0 comments on commit a256b36

Please sign in to comment.