How can I detect if page was requested via a redirect?

后端 未结 6 763
北海茫月
北海茫月 2021-01-06 05:00

On a client\'s website there are loads of redirects going to a particular page. This page somehow needs to have a way detecting whether the request was direct (URI typed in

6条回答
  •  清歌不尽
    2021-01-06 05:36

    How about:

    my $cgi = CGI->new;
    
    print $cgi->redirect(
        'http://example.com/this/page/that.html?redirect=yes'
    );
    

    What ever mechanism you are using to distinguish between redirects can then look at the query string to decide. Of course, this does not prevent users from bookmarking the URL with the redirect=yes etc.

    You could try the referer header, but that has its own problems.

提交回复
热议问题