问题描述
是否有一个htaccess的剧本我可以使用图像的URL重定向到一个实际的网页?
Is there a .htaccess script I can use to redirect the url of an image to an actual web page?
我能做些什么,以使它所以通过其地址栏键入的时候有人访问图像:的或者其他的扩展类似 http://www.sitename.com/uploads/235-file-name -here.png
What can I do to make it so when someone accesses an image via their address bar by typing in: http://www.sitename.com/uploads/192-file-name-here.jpgor other extensions likehttp://www.sitename.com/uploads/235-file-name-here.png
有将代替用户重定向到网页: http://www.sitename.com/view/192-file-name-这里/
It will instead redirect the user to the web page:http://www.sitename.com/view/192-file-name-here/
欲仍然能够把整个网站并在外部网站虽然在图像标记的图像。
I want to still be able to place the images in image tags across the site and on external sites though.
RewriteCond %{HTTP_REFERER} !^https?:\\www\.sitename\.com
RewriteCond %{REQUEST_URI} (.*)\.jpg$
RewriteRule images/(\d+)\.jpg http://www.sitename.com/view/$1.html [L,R=301]
RewriteCond %{HTTP_REFERER} ^$
可以这样修改/重写来执行我的功能?
Can this be modified/re-written to perform my function?
推荐答案
把这个在你的的.htaccess
,它会重定向可以被用户直接发送的所有请求。
注意:其他网站,正如你所提到可以把你的照片在他们的页面
put this in your .htaccess
, it will redirect all requests that are sent directly by user.
Note: Other sites,as you mentioned can put your images in their pages.
RewriteCond %{REQUEST_URI} ^/uploads/(\d+)-(.+)\.(png|gif|jpe?g|bmp)$ [NC]
RewriteCond %{HTTP_REFERER} ^$
RewriteRule (.*) http://www.sitename.com/view/%1-%2/
这篇关于的.htaccess图像的网页重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!