#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    349
    Rep Power
    12

    Get image parameters from URL with mod_rewrite


    Using mod_rewrite in .htaccess, how can I rewrite this:

    Code:
    http://example.com/300/150/7/48671.png
    to this:
    Code:
    http://example.com/?w=300&h=150&q=7&id=48671&ext=png
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,749
    Rep Power
    9397
    Code:
    ^(\d+)/(\d+)/(\d+)/(\d+)\.(allowed|extensions|here)$
    rewrites to
    Code:
    ?w=$1&h=$2&q=$3&id=$4&ext=$5
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    349
    Rep Power
    12
    Thanks! Here it is the working .htaccess file:
    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_fileNAME} !-d 
    RewriteCond %{REQUEST_fileNAME} !-f 
    RewriteRule ^(\d+)/(\d+)/(\d+)/(\d+)\.(gif|jpeg|png|jpg)$ index.php?w=$1&h=$2&q=$3&id=$4&ext=$5

IMN logo majestic logo threadwatch logo seochat tools logo