I want to stop direct access for dynamic url. If someone tries to access next link http://abc.com/gallery.php?id=1 then redirect to error404 page

Value of id=1 is dynamic and changes frequently. How to redirect if id=2 or any other value (0 to )?

php redirect code

    if($curPageURL == $url)  
        header("Location: http://abc.com/error404");
Member Avatar


Use pattern matching e.g. preg_match

if(!strpos('mysite.com',$_SERVER["HTTP_REFERER"])) header('Location: index.php')

sessions: established on the preferred access page, with appropriate robots.txt entries to please google image searchbot

HTTP_REFERER checks (oops already noted)