htaccess - rewrite question

Discussion in 'Apache' started by Psygarden, Feb 6, 2007.

  1. #1
    I was struggeling yesterday to get a dynamic rewrite working...

    I was trying to get this url:

    http://static.rad.be/i/phpthumb/php...041-2001-0.jpg&w=50&h=50&bg=ffffff&far=1&q=85

    To rewrite to this url:

    http://static.rad.be/i/phpthumb/phpThumb.php?src=/images/touratech/01-041-2001-0.jpg&w=50&h=50&bg=ffffff&far=1&q=85&fltr[]=wmi|images/watermark.png|C

    -The two numbers that are colored red are a requirement for the rule to apply... so i want to do this if the number is larger than 50
    -The green string is the only part that is relevant to me to locate the file, it should also be a parameter.

    So this should also work for:
    http://static.rad.be/i/phpthumb/php...en/148gr.jpg&w=150&h=150&bg=ffffff&far=1&q=85

    I was unable to get this to work the way i had in mind... any suggestions?
     
    Psygarden, Feb 6, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Nintendo, Feb 6, 2007 IP
  3. Psygarden

    Psygarden Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What i wanted to achive was add a parameter to an url with already a large number of parameters.

    Simplified Example:

    page.php?w=50&h=50&img=flower.jpg

    Should not be changed, while:

    page.php?w=100&h=100&img=flower.jpg

    Should be rewritten to:
    page.php?w=100&h=100&img=flower.jpg&watermark=watermark.gif|CC

    so depending on the numeral value of certain parameters i would like to add or not add a certain string to the url... I find it quite difficult to find documentation about this kind or rewrites. It seems it's generally only used to do rewrites from a readable format to a format with parameters... Is there a reason for this that i'm not aware of?

    Kind regards,
    And Thanks for the support!
    Rik
     
    Psygarden, Feb 7, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Post that simple version at *gags*

    webmasterworld.com/apache/

    If it's possible, you'll get the answer there. The mod_rewrite King is there.
     
    Nintendo, Feb 7, 2007 IP
  5. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Simple version:
    RewriteCond %{QUERY_STRING} w=([0-9]+)
    RewriteCond %1 >50
    RewriteCond %{QUERY_STRING} h=([0-9]+)
    RewriteCond %2 >50
    RewriteRule page\.php page.php?watermark=watermark.gif|CC [QSA]
    Code (markup):
    Should be fairly self explanitory - untested but in theory it should work.
     
    rodney88, Feb 7, 2007 IP