I want to do a rewrite with the following conditions:
- Directory is /images
- file has a .jpg, .png or .gif extension
I want to redirect to the following
/images/?file=filename.extension
This is not working:
RewriteRule /images/(.*\.jpg|png|gif) /images/?file=$1
Example:
/images/example.jpg
=> /images/?file=example.jpg
Thanks
In the .htaccess file, the path is stripped of the leading slash so you need to start with a
images/
instead of/images/
. Also, you can start with a^
to match the beginning of the path so that paths like/blahblah/images/something.gif
won't get rewritten. Finally, your paren will matchfoo.jpg
but notfoo.png
orfoo.gif
. Try this instead:I think you need parens to group the extensions.