简体   繁体   English

htaccess将仅重定向网页,即php和html

[英]htaccess will only redirect web pages i.e php and html

I am trying to use hotlink protection with my website and the code doesn't appear to work (I copied this off a site) 我正在尝试对我的网站使用热链接保护,但是代码似乎无法正常工作(我是从网站上复制此代码的)

So I tried redirecting everything with to an image what is hosted on a separate website to see if the rewrite was working and I found that the rewriterule would only redirect web pages such as a php file or html 因此,我尝试将所有内容都重定向到单独网站上托管的图片,以查看重写是否有效,并且我发现重写器只能重定向网页,例如php文件或html。

here is the code I used to redirect all files: 这是我用来重定向所有文件的代码:

RewriteRule ^.*$ http://www.filetransit.com/images/screen/8d3171cb63e905f67bb7685f4b033bfb_AQL_htpasswd_and_htaccess_Password_Manager.jpg [NC]

And i have turned the rewriteEngine on 我已经打开了rewriteEngine

If you want to do a hotlink protection to any url on your webpage you may use HTTP_REFERER 如果您想对网页上的任何网址进行热链接保护,则可以使用HTTP_REFERER

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://([a-z0-9]+\.)?example\.com/.*$ [NC]
RewriteRule ^(.*)$            http://example.org/image.jpg       [R,NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用htaccess文件仅将所有页面重定向到index.html,而不是重定向图像文件 - How to redirect all pages only to index.html using htaccess file and not redirect the image files 我已经看到使用 php 显示第一个图像的代码,即文件夹中的最新图像,现在我如何使代码显示第二个和第三个 - I have seen the code that displays the first image i.e latest image in a folder using php, now how do i make the code to display the second and third .htaccess图像到网页的各种重定向 - .htaccess image to web page redirect of sorts 如何在图像坐标上加速嵌套循环(即 for i in a for j in b) - How to speed up the nested loop(i.e for i in a for j in b) over image coordinates 将线条的黑白图像矢量化为无粗细的矢量(即坐标) - Vectorising black and white image of lines into vectors of no thickness (i.e coordinates) 使用PHP在HTML电子邮件中显示图像 - Display image in html e-mail with php htaccess重定向图像 - htaccess redirect for images htaccess图片重定向 - htaccess image redirect 使用.htaccess将图像重定向到页面 - Redirect images to a page with .htaccess php和htaccess,如何在一个目录中禁用图像缓存 - php and htaccess, how to disable images cache in only one directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM