0

Lets say I have a website www.mySite.com and there are a lot of pages whose links are www.mySite.com\contact.php and www.mySite.com\about.php.

What if I want that when someone enters a direct link like www.mySite.com\about.php instead of opening that page it should go to a page myPolicy.php and then myPolicy.php may\may not refer the user to the requested page....

HOW to do IT

One method I thought is have a PHP page myPolicy.php and include\require it in beginning of every page so than I can decide weather to continue the requested page or redirect somewhere else or not....

Is that okay?

Is there a better way or some best practice for this kind of thingy?

4
  • @Copas: c'mon man... its casual stuff.... Commented Aug 31, 2010 at 2:03
  • but Thanks anyways... appreciate it Commented Aug 31, 2010 at 2:03
  • Part of the larger mission of SO is to be a repository of good questions. If someone else asks the same question you have here it is likely to be closed and pointed to this question. In that case it becomes less a casual question from you and more the canonical reference for people with that question. You can always revert to your first post, although I think its a bad idea it's your prerogative. Commented Aug 31, 2010 at 16:45
  • 1
    @copas... yeah i see the point now... thanks Commented Aug 31, 2010 at 21:16

2 Answers 2

3

if you don't need much security you could just do:

if(empty($_SERVER['HTTP_REFERER']))
    redirect('myPolicy.php');

this $_SERVER['HTTP_REFERER'] can't be relied since it's provided by the browser and can be easily changed.

if you want assurance on that you will have to think of the better strategy. you could use a login system for example. you have to understand that for the server, a user clicking a link and a user requesting a url (writing it down) is just the same thing. you count on the browser info (like $_SERVER['HTTP_REFERER']) just for usability, not security.

Sign up to request clarification or add additional context in comments.

1 Comment

and put this where... what if i DO need much security... plz elaborate
2

You could require a cookie be present, redirect if it isn't, and set the cookie on the myPolicy page.

However, I would strongly advise against doing this. You will be making your site inaccessible to search engines, unusable on browsers that block cookies (or referrers, if you did it that way), uncacheable and hostile to deep-linking (which most sites would welcome).

This is not a commonly accepted practice and it is unlikely to make ‘terms of use’ any more legally binding.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.