SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing a Variable to a Redirected Page? Possible?

    I have a page that is redirected - let's say for the sake of argument that it's the following:

    www.website.com/yellow

    Which, through the magic of htaccess, behind the scenes shows www.website.com/showcolor.php?id=yellow

    Now, say I wanted to pass an additional variable, like a code?

    www.website.com/yellow?code=123

    Is this possible? And if so... how do I do it?

    and just so you know - there is no trailing .php in url.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2011
    Location
    Kolding, Denmark
    Posts
    108
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    If your rewrite rules have QSA then it should work fine.

  3. #3
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you! That did it.

  4. #4
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - an add on to this. I've currently got htaccess configured as so:

    RewriteRule ^properties/([0-9]+) properties/showprop.php?id=$1 [QSA]

    But now when I try add UTM variables in email newsletters, it serves up broken pages. Any thoughts on how to make it all coexist peacefully?

  5. #5
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does anyone know how to make mod_rewrite rules and UTM tracking codes coexist peacefully?

  6. #6
    SitePoint Zealot bronze trophy xMog's Avatar
    Join Date
    Mar 2011
    Posts
    147
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Hello bvarvel!

    I tried your use case. I have this .htaccess at the root of my site:

    Code:
    RewriteEngine on
    RewriteRule ^properties/([0-9]+) properties/showprop.php?id=$1 [QSA]
    And I created the page "/properties/showprop.php"

    In "showprop.php", I have this code:

    Code:
    <html>
    <head>
    </head>
    <body>
    Show prop:
    <?
    	echo "id: " . $_GET["id"] . "<br>";
    	echo "UTM: " . $_GET["UTM"];
    ?>
    </body>
    </html>
    When I call the URL http://localhost/properties/11?UTM=10

    The page prints out the expected result:
    Code:
    Show prop: id: 11
    UTM: 10
    So, either I didn't understand what was your question or there's something else preventing it from working.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •