Please help me to resolve hotlinking, how to prevent direct access to this URL and redirect visitors to index.php:
http://www.example.com/index.php?link=http://www.anysite.com/dir/file&name=on&email=on&submit=on
Please help me to resolve hotlinking, how to prevent direct access to this URL and redirect visitors to index.php:
http://www.example.com/index.php?link=http://www.anysite.com/dir/file&name=on&email=on&submit=on
are you searching for something like this:
if(!strpos('mysite.com',$_SERVER["HTTP_REFERER"])) header('Location: index.php')
For purposes of answering this, I'm going to assume you don't care if the same user accesses it multiple times (provided that the first visit came through the main index page). This also assumes the user will accept a cookies.
When on the main index page:
When loading a url:
Using an htaccess file is a common solution to this problem:
from http://altlab.com/htaccess_tutorial.html
This code in particular redirects anyone trying to hotlink an image.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://img148.imageshack.us/img148/237/hotlinkp.gif [L]