开发者

Another htaccess question ... Recursive RewriteRule?

开发者 https://www.devze.com 2023-03-28 10:03 出处:网络
I\'d like to apply a rewrite rule to all images within a certain directory.I tried this: RewriteRule ^/source/([a-zA-Z-_]+).(jpg|png|jpeg|gif)$ /files/$1.$2 [NC,L]

I'd like to apply a rewrite rule to all images within a certain directory. I tried this:

RewriteRule ^/source/([a-zA-Z-_]+).(jpg|png|jpeg|gif)$ /files/$1.$2 [NC,L]

But, it doesn't seem to affect images within subdirectories of the files folder? (i开发者_运维百科.e., files/image.gif, files/8994/image2.png, files/subproject/3349/image3.jpg, should all be affected. Is there a way to do that?


Try this:

RewriteRule ^source/([a-zA-Z-_\/\.]+).(jpg|png|jpeg|gif)$   files/$1.$2 [NC,L]

Remember DO NOT PUT / in beginning of RewriteRule!(e.g source/ NOT /source/)

edit:

it will rewrite source/ajsbdkjasd.aksjdbf/asldkjbfaskdf.gif to files/ajsbdkjasd.aksjdbf/asldkjbfaskdf.gif!

RewriteRule ^source/([a-zA-Z-_\/\.]+).(jpg|png|jpeg|gif)$   files/$1.$2 [NC,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消