SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot forum11's Avatar
    Join Date
    Feb 2006
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image path and mod_rewrite

    I am using this .htaccess

    RewriteEngine On
    RewriteRule ^vars/(.*)/(.*)/ index.php?a=$1&b=$2

    and using this php

    PHP Code:
    $a $_GET['a'];
    $b $_GET['b'];
    $img "images/".$a.".gif";
    echo 
    $b." for "."<img src='".$img."'>"
    When I am accessing it directly i.e.
    index.php?a=1&b=2
    Then image path is ok (images/1.gif) but if I access through this
    vars/1/2/
    Then image path is NOT ok (vars/1/2/images/1.gif which is not OK)

    Is there any solution in .htaccess to get rid of that instead of giving actual image path i.e. http://www.example.com/images/1.gif
    Do Good Have Good!

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Use a base link
    Code:
    <base href="http://www.example.com/index.php" />
    also avoid using (.*) as it is too open and would allow anything and everything through the rewrite.
    Code:
    RewriteRule ^vars/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/ index.php?a=$1&b=$2
    would be safer.

    For more light reading: http://datakoncepts.com/seo
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •