[英]redirect if user directly enters page name in URL
I have to redirect page if the user entered page name in URL.如果用户在 URL 中输入页面名称,我必须重定向页面。 I have two pages called as index.php and next.php我有两个页面分别称为 index.php 和 next.php
In index.php page there is a link called <a href="next.php">Click here</a>
.在 index.php 页面中有一个名为<a href="next.php">Click here</a>
的链接。 If i clicked on link then page is redirecting on next.php properly.如果我单击链接,则页面将正确重定向到 next.php。
Now the issue is if any user directly entered next.php on URL then the page should be redirected on index.php page.现在的问题是,如果任何用户直接在 URL 上输入 next.php,那么该页面应该被重定向到 index.php 页面。 That means the user will not able to access directly next.php这意味着用户将无法直接访问 next.php
generally you want to check the user (account, session ID) against a server to prevent this kind of unwanted routing.通常,您希望针对服务器检查用户(帐户、会话 ID)以防止这种不需要的路由。
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.例如,这可以通过将整个页面(路由)包装在检查权限/会话 ID 等的自定义组件/函数中来完成。如果用户不属于页面(在您的情况下为next.php
),请重新路由他回到或某种主页。
This technique is called route protection .这种技术称为路由保护。 Check this article that talks about the issue.查看这篇讨论该问题的文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.