Hey guys, I am having an issue using mod_rewrite to work correctly when using paging numbers. I will explain with the example below: I have a downloads section on my website, which has a listing page that be filtered based on the the download's category. This listing page also is filtered through pagination. The way I am currently handling this is by using the URL in the following format: display page 1 in the listing of downloads in category "categoryname" [url]mysite.com/downloads/categoryname/[/url] Code (markup): display page 2 in the listing of downloads in category "categoryname" [url]mysite.com/downloads/categoryname/2/[/url] Code (markup): etc, etc These are the rules I am using to achieve this: RewriteRule ^downloads/([^/\.]+)/([^/\.]+)/?$ downloads.php?category=$1&page=$2 [L] RewriteRule ^downloads/([^/\.]+)/?$ downloads.php?category=$1 [L] RewriteRule ^downloads/?$ downloads.php?category=all [L] Code (markup): This works just fine. However, I am now wanting each download to have it's own details page using the following URL format: [url]mysite.com/downloads/categoryname/downloadname/[/url] Code (markup): As you can see the "downloadname" space is already utilized by "page", both in space $2. How can I achieve something like this? I hope my example explained my issue properly. Thanks, Kyle
Hmh... this was an interesting one So your pagination part can actually be ONLY a number, so this is something we could use here. It can't be any other character then a number so instead of using ([^/\.]+) to match that number, let's use ([0-9]+) instead. It will match only numbers (1, 5, 10, 5821782, or any other number, but only number, no alpha or other characters). After that, let's use that syntax you already used "/([^/\.]+)/([^/\.]+)/" for this new mod rewrite rule you wish to add. Anyway... to get the story short, let's try this: RewriteRule ^downloads/([^/\.]+)/([0-9]+)/?$ downloads.php?category=$1&page=$2 [L] RewriteRule ^downloads/([^/\.]+)/([^/\.]+)/?$ downloads.php?category=$1&filename=$2 [L] RewriteRule ^downloads/([^/\.]+)/?$ downloads.php?category=$1 [L] RewriteRule ^downloads/?$ downloads.php?category=all [L] Code (markup): What was changed here were the first two lines... actually the first one was changed, and the second one was added. Please NOTE that I have improvised that "downloads.php?category=$1&filename=$2" part, as I do not know to what you wish to redirect this new links, since you haven't mentioned that. Also, VERY IMPORTANT part is that you shouldn't give those first two lines another order. The first line I wrote MUST be ALWAYS in front of the second line. Other lines are not that important, but this first one MUST go always before the second one, or else your pagination will stop working and only this new rule will work. Why? Because the second rule mentioned above can apply also to your pagination pages, but since it was already assigned to another script code by the first line, then it will be ignored in the second rule, and used properly. I gave it a quick test on my server, and it worked fine with few simple pages. I don't see a reason though why it shouldn't work with your site