Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Posts
    135
    Thanks
    83
    Thanked 0 Times in 0 Posts

    Mod Rewriting A ?x=

    I have the following mod rewrite process which works
    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)\.([^/]*) http://127.0.0.1/test/test.php?i=$1&p=$2&t=$3 [L]

    Example URL: 127.0.0.1/test/1/999.jpg. Redirects To: 127.0.0.1/test/test.php?i=1&p=999&t=jpg

    I would also like to add in a variable after the image type but in an actual variable format such as:
    http://127.0.0.1/myzon/1/999.jpg?r=1

    Does anybody know how I could ammend my rewrite function to allow this & then redirect to test.php?i=$1&p=$2&t=$3&r=$4?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You probably don't need too. Add QSA as a flag to the end of your pattern and it should append a querystring onto it for you (ie: [QSA,L]). Unfortunately (I don't do a lot of rewriting myself) I'm not sure if its smart enough to ignore the ?, and just continue (I'm not certain if the result will be: http://127.0.0.1/test/test.php?i=$1&p=$2&t=$3&r=1 or if it will be http://127.0.0.1/test/test.php?i=$1&p=$2?t=$3, but my suspicion is it will be the former which is good).
    See if that works for you.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    Sussex_Chris (01-20-2011)

  • #3
    Regular Coder
    Join Date
    Apr 2009
    Posts
    135
    Thanks
    83
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    You probably don't need too. Add QSA as a flag to the end of your pattern and it should append a querystring onto it for you (ie: [QSA,L]). Unfortunately (I don't do a lot of rewriting myself) I'm not sure if its smart enough to ignore the ?, and just continue (I'm not certain if the result will be: http://127.0.0.1/test/test.php?i=$1&p=$2&t=$3&r=1 or if it will be http://127.0.0.1/test/test.php?i=$1&p=$2?t=$3, but my suspicion is it will be the former which is good).
    See if that works for you.
    I always forget simple things like that, sorted now, thanks a lot


  •  

    Posting Permissions

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