Mod RewriteRule Help : Accepting Variable Number Of Arguments

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

 



Hello,

Here is an example URL I'm trying to create a RewriteRule for:

index.php?section=help&page=test&mode=IN&item=4&action=edit

I have a rule that works when the request URL contains the appropriate number of arguments but does not work when there are fewer arguments than the Rule expects. I thought by creating multiple (similar) rules would resolve but no luck. Here is what I have that works as long as I pass all required arguments:

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

The above rule correctly passes http://domain.com/help/test/IN/4/edit to my script as /index.php?section=help&page=test&mode=IN&item=4&action=edit .

I tried creating 5 rules so that, if Apache saw fewer arguments, it would go down to the next rule but that didnt work like I thought it would:

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

How do I write the rule(s) so that, if fewer arguments are passed, it will still work?

Any help would be greatly appreciated.

Thank you,

Kris

_________________________________________________________________
Watch free concerts with Pink, Rod Stewart, Oasis and more. Visit MSN Presents today. http://music.msn.com/presents?icid=ncmsnpresentstagline&ocid=T002MSN03A07001


---------------------------------------------------------------------
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