Apache Rewrite rule help needed, please

Posted on 2007-07-31
Last Modified: 2010-03-04
Hi, I need help tweaking a mod rewrite.

Right now users can come to my site with a url of (or /catalog/product/123/)

And it's rewritten to

Here's the rule(s) that do that:

RewriteRule ^/catalog/product/([A-Za-z0-9]+)$ /catalog/product.php?itemNo=$1 [L]
RewriteRule ^/catalog/product/([A-Za-z0-9]+)/$ /catalog/product.php?itemNo=$1 [L]

However, I need to be able to support additional parameters on the URL and carry them along in the rewrite... so for example, if the user comes to

Then I need that to be rewritten to:

The extra vars won't always be "v1" and "v2" -- I need a rewrite rule that will keep it open and just carry along whatever GET parameters were appended to the URL.

I've tried many times over to get this working, without luck ;-) Please help!

thank you---

Question by:pnoeric
    LVL 16

    Accepted Solution

    Does it not work if you append the query string using the server variable, like this:

    RewriteRule ^/catalog/product/([A-Za-z0-9]+)/?$ /catalog/product.php?itemNo=$1&%{QUERY_STRING} [L]

    (I've collapsed the rules into one by making the final forward-slash optional.)

    Author Comment

    yes! thank you so much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now