benyboi Posted December 26, 2007 Share Posted December 26, 2007 Ok, i am trying to make mod_rewrite forward requests for images to a php page with the image as a variable. e.g. osij9wu09iqwioj0e.jpg fowards to index.php?image=osij9wu09iqwioj0e.jpg i currently have: Options +FollowSymLinks RewriteEngine on RewriteRule ^([a-z/0-9/.]+)$ index.php?image=$1 [L] but then because there are not many arguments it forwards to index.php but then to index.php again and gets stuck in a loop... what do i have to change to the rule so that it doesnt work if the page requested is index.php? thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted December 26, 2007 Share Posted December 26, 2007 RewriteRule ^([a-z0-9.]+).jpg$ index.php?image=$1 [L] Quote Link to comment Share on other sites More sharing options...
benyboi Posted December 26, 2007 Author Share Posted December 26, 2007 thats for that one! it almost works but can be changed in 2 ways. a) not all my images are jpg, some gif/png etc b) with that, the extension of the image isnt copied to the variable. but yes, if they were all jpgs that would be easy to solve but theyr not thanks for your help! Quote Link to comment Share on other sites More sharing options...
trq Posted December 26, 2007 Share Posted December 26, 2007 RewriteRule ^([a-z0-9]+)\.(jpg|png|gif)$ index.php?image=$1.$2 [L] Just add more image types in here (jpg|png|gif) sperated by | if needed. Quote Link to comment Share on other sites More sharing options...
benyboi Posted December 26, 2007 Author Share Posted December 26, 2007 thank you so much your a legend! i have never thought about needing $2. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.