mod_rewrite and .htaccess again...

Posted on 2004-11-19
Last Modified: 2010-03-04

I would appreciate help on this one.
What I want to do is to translate everything after the main url into a parameter.

for example:

should all be redirected to

with the respective end of the url transfered as a parameter. It doesn't matter if it's the parameter name, or the value of some named parameter.

Now, when I've tried to do it myself, all that happens is that I get caught in an infinite loop to the main url, not very surprisingly.
So what I also need is a condition that checks if the url contains a questionmark '?'. In that case the request should not be redirected.

I'm a pure novice to mod_rewrite so I really need help from you guys!


Question by:Nick_72
    LVL 16

    Assisted Solution

    LVL 16

    Expert Comment

    LVL 5

    Accepted Solution

    Use this

            RewriteCond     %{QUERY_STRING} ^$
            RewriteRule   ^/(.*)$ /?$1 [R,L]

    to pass url to specific variable, then modify RewriteRule

            RewriteRule   ^/(.*)$ /?variable=$1 [R,L]

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    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…

    754 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

    14 Experts available now in Live!

    Get 1:1 Help Now