如何通过重定向检测页面是否被请求? [英] How can I detect if page was requested via a redirect?

查看:148
本文介绍了如何通过重定向检测页面是否被请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在客户的网站上有大量重定向到特定页面。这个页面需要以某种方式检测请求是否是直接的(手动输入URI)或重定向。


  1. 全部的重定向是301重定向。由于SEO规则增加了指标需要避免。 (谷歌索引URL单独的值)我试图检查所有的环境变量,但它们都是空的(假设是正常的),在这方面内部重定向没有任何区别(我认为)。

  2. 检测需要实时发生,因此日志文件不是一个选项。


这个过程简而言之,参数通过脚本在cookie中注册,然后301重定向到内容被cookie驱动的页面。当cookie被注册时,当有人在地址栏中重新输入地址时,内容不会变回原始状态。



我希望这是有道理的。



以前:我在考虑状态代码,但我不确定是否有方法在目标页面上阅读它。 (我们已经明确表示它不会起作用)

解决方案

受到Brian的启发,我退后一步,看看究竟是什么正在造成我的问题。

这个问题可能没有答案,但有一个解决方案可以部分解决问题。
通过使用会话cookie,修改后的内容将仅存在于该特定会话中,以便下次再次访问原始内容。
这并没有改变这个事实,即重新输入地址栏中的网址仍然会导致页面使用cookie。



谢谢大家的努力帮助。

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 manually) or a redirect.

  1. All of the redirects are 301 redirects. Due to SEO rules added indicators need to be avoided. (Google indexes urls with values separately)

  2. I have tried checking all environment variables but all of them are empty (which assume is normal) and in this respect internal redirects are not any different (I reckon).

  3. Detection needs to happen real time so log files are not an option.

The process in short, parameters are registered in cookies via a script, then it 301 redirects to the page where the content is cookie driven. While cookies are registered the content won't change back to original when someone retypes the address in the address bar.

I hope this makes sense.

PREVIOUSLY: I was thinking about status codes, but I am not sure if there is a way to read that on the destination page or not. (We've clearified that it won't work)

解决方案

Inspired by Brian I toke a step back and looked at what exactly is causing my problem.

There may not be an answer to this question but there is a solution that partially solves problem. By using session cookies the modified content will only exist for that particular session so next time the original content becomes accessible again. This doesn't change the fact that re-enterying the url in the addressbar will still result in the page using the cookie.

Thank you all for trying to help.

这篇关于如何通过重定向检测页面是否被请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆