1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with some simple coding which I'm confused about

Discussion in 'BlackHat Lounge' started by brent360, May 4, 2011.

  1. brent360

    brent360 Junior Member

    Feb 16, 2011
    Likes Received:
    Howdy guys. I need a little help with mod_rewrite.

    On one of my websites I use a query string appended to the root domain to pass a variable into a php function which decides how to display the page. Example: site.com/?stuffhere=whatever will pass "whatever" to my "stuffhere" function which transforms a shortcode on the page according to the rules outlined in a "whatever" file. After a certain amount of time on the page, "whatever" instructs the page to redirect to another one and to disallow visitors from reaching the page displayed with the original query string attached (using cookies/host as a reference).

    I use mod_rewrite to transform site.com/?stuffhere=whatever to site.com/stuffhere/whatever for the sake of user-friendliness.

    Here's my problem:
    When the function finally redirects the end-user away from site.com/?stuffhere=whatever to site.com/?stuffhere=whatever-expired, the URL transforms back to the non-rewritten URL (thereby demonstrating the query string). (So upon redirection, the URL displays site.com?stuffhere=whatever-expired instead of site.com/stuffhere/whatever-expired.)

    Anyone know how to fix this? Should be something simple and quick but I'm not particularly familiar with mod_rewrite or permalink rewrites in general.

    To clarify: I want to maintain the site.com/stuffhere/whatever format even after the redirect which prompts the URL transformation. I'm looking to accomplish this with a rewrite rule--I'm sure it's possible but I have no clue why it wouldn't automatically maintain the rewrite to begin with.

    Current rule:
    RewriteRule ^stuffhere/([^/]*)/$ /?stuffhere=$1 [L]