Lets say, I create page1 and page2 in wordpress, in Page1 there is a hyperlink which takes me to page2. How do I ensure that visitor has clicked that hyperlink and have come to page2 and not directly on page2, by typing page2 url in the address bar.

if someone has come directly to page2 I want them to be redirected automatically to page1.
In old days I was able to crack this with some javascript and and later also in ASP.
If I recollect correctly had used querystring and url redirect.

What is easy way in wordpress? unfortunately in wordpress plugin directory all I am getting is plugins for 404 and 301, Please help me here.

2 Answers
2

if ( ! isset( $_SERVER['HTTP_REFERER'] ) AND 'your_page1' !== $_SERVER['HTTP_REFERER'] )
{
    exit( wp_redirect( $target, 301 ) );
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *