1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mod Rewrite

Discussion in 'HTML, Graphics & Programming' started by toastyman, 7 Jun 2006.

  1. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Hey,

    Could someone point me in the right direction with this?

    Code:
    RewriteRule ^images/teambanner/([A-Za-z0-9-]+)\.jpg/?$ /images/teambanner.php?id=$1 [L]
    
    It should basically rewrite from www.yourdomain.com/images/teambanner/abc123.jpg to /images/teambanner.php?id=abc123
     
    Last edited: 7 Jun 2006
  2. unknowndomain

    Mobster

    Joined: 18 Apr 2004

    Posts: 2,613

    Location: Herne Hill, London

    This is what id do, very similar to yours, you can compound A-Za-z with A-z, I would also allow _ , and finaly, [NC] allows a mIx oF UPPER and lower cAsE letters. apart from that it should work, obviously you need to have the RewriteEngine On statment and the Options +... Helps for some webservers, like mine where it won't work without that.

    Code:
    Options +FollowSymlinks -indexes
    RewriteEngine On
    
    RewriteRule ^images/teambanner/([A-z0-9-_]+)\.jpg/?$ /images/teambanner.php?id=$1 [NC]
    
     
  3. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Argh! That gave me a 500 Internal Server Error, and the following in the error log:
     
  4. unknowndomain

    Mobster

    Joined: 18 Apr 2004

    Posts: 2,613

    Location: Herne Hill, London

    Ok take the _ out and try it again
     
  5. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Spot on works perfectly :)

    Thanks very much!
     
  6. unknowndomain

    Mobster

    Joined: 18 Apr 2004

    Posts: 2,613

    Location: Herne Hill, London

    cool you probably just need to escape the _ by putting \_ but if u dnt need it dnt worry