有没有办法传递除会话之外的变量并获取变量?

发布于 2024-10-06 03:20:26 字数 335 浏览 0 评论 0原文

我的问题不太容易描述......对我来说:-)所以请宽容我。

我有多种查看列表的方法。这意味着,有一些可能性如何进入并创建显示我的列表的视图。这对于并行打开的浏览器选项卡来说效果很好,并且是理想的。

如果我单击列表中的某个项目,我就会看到该项目的详细视图。

在这个视图中,我想知道链接是从哪种类型的列表中“调用”的。第一个问题是,引荐来源网址始终相同,第二个问题是:我不应该在 url 中附加 get 变量。 (它也不应该是提交的表单)

如果我将其存储到会话中,那么在并行选项卡中工作时我也会覆盖我的会话参数。

仍然实现我的目标的最佳方法是什么,即知道之前的列表处于哪种模式。

My problem is not so easy to describe ... for me :-) so please be lenient towards me.

I have several ways to view a list. which means, there are some possibilities how to come to and create the view which displays my list. this wokrs well with parallel opend browser tabs and is desired though.

if I click on an item of my list I come to a detail-view of that item.

at this view I want to know from which type of list the link was "called". the first problem is, that the referrer will allways be the same and the second: I should not append a get variable to the url. (and it should not be a submitted form too)

if I store it to the session, I will overwrite my session param when working in a parallel tab as well.

what is the best way to still achive my goal, of knowing which mode the previous list was in.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年不长 2024-10-13 03:20:26

您需要使用某物来区分一个页面和另一个页面,否则您的服务器将不知道您要求什么。

您可以发布您的请求:这将隐藏 URL 参数,但会妨碍您的后退按钮功能。

您可以获取您的请求:这将使您的网址更加“丑陋”,但您应该能够通过传递简短、简洁的标识符(如 www.example.com/listDetail?id=12)来解决这个问题。

如果您可以设置 mod_rewrite,那么您可以 GET 请求到像 www.example.com/listDetails/12 这样的 url,apache 会在幕后重写该请求,使其看起来更像 www.example.com/listDetails?id=12 <强>但用户永远不会看到它——他们只会看到原始的、干净/友好的版本。

您说您无权访问服务器配置 - 我认为这是因为您位于共享服务器上? 大多数共享服务器已经安装了mod_rewrite。虽然 apache 虚拟主机通常是放置重写规则的最合适位置,但它们也可以放置在您想要控制的任何目录中的 .htaccess 文件中。 (有时服务器配置会禁用此功能,但通常在共享主机上启用此功能)查看创建 .htaccess 文件以及如何使用 mod_rewrite

You need to use something to differentiate one page from another, otherwise your server won't know what you're asking for.

You can POST your request: this will hide the URL parameters, but will hinder your back button functionality.

You can GET your request: this will make your URLs more "ugly" but you should be able to work around that by passing short, concise identifiers like www.example.com/listDetail?id=12

If you can set up mod_rewrite, then you can GET requests to a url like www.example.com/listDetails/12, and apache will rewrite the request behind the scenes to look more like www.example.com/listDetails?id=12 but the user will never see it -- they will just see the original, clean/friendly version.

You said you don't have access to the server configuration -- I assume this is because you are on a shared server? Most shared servers already have mod_rewrite installed. And while the apache vhost is typically the most appropriate place to put rewrite rules, they can also be put in a .htaccess file within any directory you want to control. (Sometimes the server configuration disables this, but usually on a shared host, it is enabled) Look into creating .htaccess files and how to use mod_rewrite

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文