|
|||||||
New to SitePoint Forums? Register here for free!
|
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Zealot
![]() ![]() Join Date: Jan 2004
Location: west of the divide
Posts: 154
|
mod_rewrite directories to fuseactions - [N], path-info, and infinity
I'd like to use mod_rewrite to disguise the Fusebox nested circuit model (dot notation) as nested directories. That is, if the user requests
http://www.example.com/products/skis/alpine/ I want to rewrite them to http://www.example.com/index.php?action=products.skis.alpine The key here is that there can be an arbitrary number of items in the dot-delimited list. (In practice, it rarely goes more than 3 deep, but I'd like this to be completely flexible.) So, here's the problem: to address the arbitrary length of the action, I decided to try using [N] in my RewriteRule. And it almost works. But unfortunately, the path-info is getting appended to my rewritten URI, throwing it into a loop. Here is the full text of my .htaccess file. Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} !favicon.ico [NC]
RewriteCond %{REQUEST_URI} !robots.txt [NC]
RewriteCond %{REQUEST_URI} !images/ [NC]
RewriteRule ^([^/]+)/(.*)$ $1.$2 [N]
RewriteCond %{REQUEST_URI} !index.php [NC]
RewriteRule ^([a-z0-9.]+) index.php?action=$1&%{QUERY_STRING} [L]
So if I request http://www.example.com/products/skis/alpine/ , I'll see the following RewriteLog entries: Code:
add path-info postfix: /www/products -> /www/products/skis/alpine strip per-dir prefix: /www/products/skis/alpine -> products/skis/alpine applying pattern '^([^/]+)/(.*)$' to uri 'products/skis/alpine' RewriteCond: input='/products/skis/alpine' pattern='!favicon.ico' => matched RewriteCond: input='/products/skis/alpine' pattern='!robots.txt' => matched RewriteCond: input='/products/skis/alpine' pattern='!images/' => matched rewrite products/skis/alpine -> products.skis/alpine add per-dir prefix: products.skis/alpine -> /www/products.skis/alpine Code:
add path-info postfix: /www/products.skis/alpine -> /www/products.skis/alpine/skis/alpine Code:
strip per-dir prefix: /www/products.skis/alpine/skis/alpine -> products.skis/alpine/skis/alpine applying pattern '^([^/]+)/(.*)$' to uri 'products.skis/alpine/skis/alpine' RewriteCond: input='/products/skis/alpine' pattern='!favicon.ico' => matched RewriteCond: input='/products/skis/alpine' pattern='!robots.txt' => matched RewriteCond: input='/products/skis/alpine' pattern='!images/' => matched rewrite products.skis/alpine/skis/alpine -> products.skis.alpine/skis/alpine Code:
add per-dir prefix: products.skis.alpine/skis/alpine -> /www/products.skis.alpine/skis/alpine add path-info postfix: /www/products.skis.alpine/skis/alpine -> /www/products.skis.alpine/skis/alpine/skis/alpine strip per-dir prefix: /www/products.skis.alpine/skis/alpine/skis/alpine -> products.skis.alpine/skis/alpine/skis/alpine applying pattern '^([^/]+)/(.*)$' to uri 'products.skis.alpine/skis/alpine/skis/alpine' RewriteCond: input='/products/skis/alpine' pattern='!favicon.ico' => matched RewriteCond: input='/products/skis/alpine' pattern='!robots.txt' => matched RewriteCond: input='/products/skis/alpine' pattern='!images/' => matched rewrite products.skis.alpine/skis/alpine/skis/alpine -> products.skis.alpine.skis/alpine/skis/alpine add per-dir prefix: products.skis.alpine.skis/alpine/skis/alpine -> /www/products.skis.alpine.skis/alpine/skis/alpine add path-info postfix: /www/products.skis.alpine.skis/alpine/skis/alpine -> /www/products.skis.alpine.skis/alpine/skis/alpine/skis/alpine .... So... Can I do something to keep that path-info from being postfixed? or am I barking up the wrong tree using the [N] flag at all? |
|
|
|
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 01:05.









Threaded Mode