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");

Recommended Answers

Use pattern matching e.g. preg_match

Jump to Post

All 3 Replies

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.