简体   繁体   English

如果用户直接在 URL 中输入页面名称,则重定向

[英]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.

相关问题 如果用户直接在URL中输入页面名称,如何重定向页面 - How to redirecting page if user directly entered page name in URL 如果用户通过输入URL直接导航到默认页面,则将用户重定向到默认页面(不登录) - redirect the users to default page (no login) if user navigates to the page directly by typing the URL 用户在字段中输入特定文本后尝试更改页面上的网址 - Trying to change a url on a page after a user enters specific text into a field Javascript / Php-当直接在URL中键入操作表单页面时重定向 - Javascript/Php - Redirect when action form page typed directly in URL 从URL中获取用户名,然后使用带有该用户名的查询字符串进行重定向 - Take the user name from the URL and redirect with a query string with that user name 当用户进入页面时显示一个弹出窗口 - Displaying a popup when user enters a page 直接通过url访问私有子域时重定向到我的登录页面 - redirect to my login page when accessing private subdomains directly through url 如果当前网址包含,JS会将用户重定向到其他页面。 - JS redirect user to different page if the current url contains . 当用户单击请假页面JAVASCRIPT时,重定向到特定的URL - Redirect to a specific URL when user click on leave page JAVASCRIPT 用户无需登录即可直接访问文件时,如何重定向登录页面 - How to redirect login page when the user to access the file directly without login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM