Re: Mod RewriteRule Help : Accepting Variable Number Of Arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Reply-To: users@xxxxxxxxxxxxxxxx
To: users@xxxxxxxxxxxxxxxx
Subject: Re: 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@xxxxxxxxxxx> 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@xxxxxxxxx

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


_________________________________________________________________
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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux