문제

I have a doubt in .htaccess

Here is my code :

index.php

Welcome Page
<img src='image/one.png'>

The Image should be visible in the website but it should not be access if entered the url as xxx.com/image/one.png

I am using the following .htaccess

Options -Indexes
ErrorDocument   403 error.php

I read the following question but it didn't cleared me

How can i update my .htaccess file to make it possible ?

Allow file access from code, but block from browser?

도움이 되었습니까?

해결책

You can do referrer based check to prevent direct access to images. Place this rule in your root .htaccess:

RewriteEngine On

RewriteCond %{HTTP_REFERER} !localhost [NC] 
RewriteRule \.(jpe?g|gif|bmp|png)$ - [F,NC]

But remember that HTTP_REFERER can be manipulated by clients.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top