skip to Main Content

I have a file that I want to be able to download from a page so I want it to be accessible by a link, but I want that the same URL isn’t reachable by direct link for example putting it in the browser address bar.

I tried deny all in .htaccess but that didn’t let me to access it via link.

Is there a way to let access to a resource only via link?

2

Answers


  1. Try with below rule,

    order deny,allow
    deny from all
    allow from 127.0.0.1
    allow from localhost
    
    Login or Signup to reply.
  2. You can inspect “Referer” header and deny access if it is not from your web site:

    RewriteEngine On
    RewriteCond %{HTTP:Referer} !^http://example.com
    RewriteRule link-only.html - [F]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search