top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Stop the Image URL in apache

0 votes
729 views

While clicking on the image it opens into the browser. I dont want to allow client to open the image in browser as separate url. I have blocked the /image/ directory from access/listing , but the image is opening.

How to stop that in apache. Please help me.

posted Jul 28, 2014 by Satish Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Try the below code in .htaccess and hopw it should work.

RewriteEngine On
Options -Indexes
RewriteBase /
RewriteCond %{HTTP_REFERER} !^%{HTTP_HOST}$ [NC]
RewriteRule .(swf|gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx)$ [R,L]
answer Jul 28, 2014 by Jai Prakash
–1 vote

Not possible. There is nothing in the http protocol that differentiates between a file being displayed inline inside other content and being downloaded separately. All the webserver knows is that the file was requested from the server and it delivers that file.

There are tricks you can do with client-side javascript, or with checking the referrer or user agent, etc. but all of them are easy to circumvent, and note that regardless of what you do that file has to be downloaded in order to be displayed in any capacity.

answer Jul 28, 2014 by Alok Sharma
Similar Questions
+5 votes

I have an image with white background and want to remove it? any suggestion on tool and procedure to do it.

+2 votes

What is the easiest way to convert a webpage into a jpg or png file? I've seen several programs that can do
various conversions, but nothing open source that can do it in a single conversion.

–2 votes

(a) Write a Java program the decomposes a well-formed URL input into its components: scheme (protocol),
hostname, port number, and the resource (le).

(b) Reconstruct the decomposed URL in part (a) into its equivalent one, but replace the hostname with its IP
address.
Tip: Have a closer look at the java.net.URL API and the IdentifyHostIP.java.txt from

...