0

I want to restrict a file server just for people come from an specific URL: http://graymind.ir How should I config .htaccess file to do this.

1
  • Please remember that referrer restrictions are only useful for preventing unsophisticated people from accessing a site. Anyone mildly familiar with HTTP will be able to fake the necessary headers and access the server anyway.
    – larsks
    Aug 30, 2013 at 15:14

1 Answer 1

3

This is one possibility using the mod_rewrite:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://graymind.ir/.* [NC]
    RewriteRule .* - [F]

Basically it's checking if the referer starts with http://graymind.ir/ (non case sensitive), if so then it just rewrites any URL to a 403 Forbidden

4
  • isn't an "!" at the beginning of ^http... needed? Aug 30, 2013 at 15:23
  • He says that he wants to deny requests with that referer. With a ! it would mean that he wants to deny all except the ones from graymind.ir
    – replay
    Aug 30, 2013 at 15:27
  • my mistake, sorry Aug 30, 2013 at 15:34
  • sorry again, i added your code and it works perfect plus an "!" mark, but now it doesn't let download manager get the download link from the main site "graymind.ir", is there any way to fix this? Sep 5, 2013 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .