.htaccess dynamic imageurl rewrite

这一生的挚爱 提交于 2019-12-23 21:22:10

问题


I want to redirect all my product images to an external site using htaccess. However I cant figure out how to use dynamic variables, the image-url looks like this:

httpz://localhost/oc1505/image/80x80-10035.jpg

Where 80x80 is the height and the width, and the 10035.jpg is the link to the external image. So in this case I would like to redirect it to an url that looks like:

httpz://www.othersite.nl/imgs/prd/kln/10035.jpg

how ever if the source image is 150x150-10035.jpg it should redirect to.

httpz://www.othersite.nl/imgs/prd/std/10035.jpg

And I have a few other formats that I would like to redirect.

If someone could help me out a little I would be very happy.


回答1:


Try this:

RewriteEngine on
RewriteRule 80X80-(.*)$ https://www.othersite.nl/imgs/prd/kln/$1
RewriteRule 150x150-(.*)$ https://www.othersite.nl/imgs/prd/std/$1


来源:https://stackoverflow.com/questions/6410957/htaccess-dynamic-imageurl-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!