Apache - rewrite images to php file with .htaccess

后端 未结 3 2073
慢半拍i
慢半拍i 2020-12-10 21:14

I\'m looking for a way to rewrite all my image requests from one folder into some.php file, while preserving the original image url (or par

3条回答
  •  無奈伤痛
    2020-12-10 21:37

    Considering what you mention in the comments and that the previous rules didn't work, I edited the message, this is what i have now.

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/(.*)\.jpg [NC]
    RewriteRule ^folder/img/([\w]*\.jpg)$ folder/some.php?img=img/$1[R=301,L]
    

    If folder is al variable, you can change that for (\w*) and add the reference in the right side of the rule.

    Hope this helps.

    Bye

提交回复
热议问题