简体   繁体   中英

redirect if user directly enters page name in URL

I have to redirect page if the user entered page name in URL. I have two pages called as index.php and next.php

In index.php page there is a link called <a href="next.php">Click here</a> . If i clicked on link then page is redirecting on next.php properly.

Now the issue is if any user directly entered next.php on URL then the page should be redirected on index.php page. That means the user will not able to access directly next.php

generally you want to check the user (account, session ID) against a server to prevent this kind of unwanted routing.

This can be done for example by wrapping entire pages (routes) in a custom component / function that checks permissions / session ID / etc. In the case the user doesn't belong on the page ( next.php in your case), reroute him back or to some sort of a home page.

This technique is called route protection . Check this article that talks about the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM