开发者

.htaccess rewrite remote image location

开发者 https://www.devze.com 2023-02-21 00:51 出处:网络
with .htaccess below i can rewrite image location from http//mysite/folder/test.jpg to http//mysite/test.jpg

with .htaccess below i can rewrite image location from http//mysite/folder/test.jpg to http//mysite/test.jpg

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^pic.jpg /folder/pic.jpg

but when i tried with remote site

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^img.jpg http/remotesite/img.jpg

i can't rewrite it to http//mysite/img.jpg because its redir开发者_JS百科ected to original location and my question is, it is possible to rewrite remote image location with .htaccess?

thanks

SOLVED

using php readfile()

 <?php
 header("Content-Type: image/jpeg");
 $img = $_GET['img'];
 $url =  "http://remote/image.php?img=".$img;
 readfile("$url");
 ?> 

and .htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^(*.jpg)$ images.php?img=$1[L]


Options +FollowSymlinks
RewriteEngine On
RewriteRule ^img.jpg http://remotesite/img.jpg
0

精彩评论

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