httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristopher Yates" <kris_yate...@hotmail.com>
Subject Re: [users@httpd] Mod RewriteRule Help : Accepting Variable Number Of Arguments
Date Sun, 01 Apr 2007 03:06:59 GMT
Hi Eric,

Changing to .+ seems to work fine.  I have only one issue left.  The issue 
is a server error when only one argument is passed.  Here is what I have 
that works when more than one argument is passed:

RewriteRule ^(.+)/(.+)/(.+)/(.+)/(.+)$ 
/index.php?section=$1&page=$2&mode=$3&item=$4&action=$5 [L]
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ 
/index.php?section=$1&page=$2&mode=$3&item=$4 [L]
RewriteRule ^(.+)/(.+)/(.+)$ /index.php?section=$1&page=$2&mode=$3 [L]
RewriteRule ^(.+)/(.+)$ /index.php?section=$1&page=$2 [L]

I thought that, by creating one last rule at the bottom of my list, 
mod_rewrite would catch all instances of when only one argument is passed:

RewriteRule ^(.+)$ /index.php?section=$1 [L]

Adding this final rule breaks everything, resulting in ye olde 'endless 
loop' error for all requests.

I found the following rule as a solution at 
http://forums.searchenginewatch.com/showthread.php?t=3925 but I still get 
the same problem, though the documentation I found said it should work:

RewriteRule ^([^/]+)/?$ /index.php?section=$1 [L]

Any ideas?

Thank you,

Kris

>From: "Eric Covener" <covener@gmail.com>
>Reply-To: users@httpd.apache.org
>To: users@httpd.apache.org
>Subject: Re: [users@httpd] Mod RewriteRule Help : Accepting Variable Number 
>Of Arguments
>Date: Sat, 31 Mar 2007 22:16:09 -0400
>
>On 3/31/07, Kristopher Yates <kris_yates64@hotmail.com> wrote:
>>Hi Dragon,
>>RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/?$
>>/index.php?section=$1&page=$2&mode=$3&item=$4&action=$5 [L]
>>
>>Parsing http://domain.com/section/page/mode/item/action/
>>
>>Results:
>>_REQUEST[section] = "section/page"
>>_REQUEST[page] = "mode"
>>_REQUEST[item] = "action"
>>_REQUEST[action] = empty
>
>All the asterisks are greedy, and the one you expect to be 'action'
>doesn't have anything left to match but the forward slash but the 0
>characters after the slash following "action".  Try making the
>previous expressions non greedy, and maybe use + instead of *
>
>--
>Eric Covener
>covener@gmail.com
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>

_________________________________________________________________
Get a FREE Web site, company branded e-mail and more from Microsoft Office 
Live! http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message