如何使用 PHP 根据用户的来源将他们发送到特定页面
我想要做的是使用 PHP 根据用户在我网站上的位置将他们转发到特定页面。(基本上这是一个下一个按钮功能)
所以我想做的是让 PHP 检查引用 url,然后根据该值转发。
像这样的东西:(注意我不能发布多个网址,所以想象一下所有网址前面都有http://)
如果网址:mysite.com/gallery1/,则转发到:mysite.com/gallery2/
如果网址:mysite.com/gallery2/,则转发到:mysite.com/gallery3/
如果网址:mysite.com/gallery3/,则转发到:mysite.com/gallery4/
如果引用网址不在列表中或者他们只是直接输入 php 脚本网址,请将其发送到 mysite.com/nogallery/
我想使用数据库来存储数据。基本上它有 2 列。 1 表示引用网址,1 表示转发网址。
如果您能帮助我,我将不胜感激。
What I want to do, is use PHP to forward users to specific pages based on where they are coming from on my site.(basically this is a next button functionality)
So what I'd like to do is have PHP check the referring url and then forward based on that value.
Something like this:(note I can't post multiple urls, so imagine that there is the http:// in front of all of them)
If url: mysite.com/gallery1/ then forward to: mysite.com/gallery2/
If url: mysite.com/gallery2/ then forward to: mysite.com/gallery3/
If url: mysite.com/gallery3/ then forward to: mysite.com/gallery4/
And if the referring url isn't on the list or they just typed in the php script url directly, send them to mysite.com/nogallery/
I'd like to use a database to store the data. Basically it'd have 2 columns. 1 for referrer url, and 1 for the forwarding url.
If you could help me out it'd be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你已经知道该怎么做了。如果您想将 URL 存储在数据库中,那没问题,但想象一下您有这样的结构:
Sounds like you know what to do already. If you want to store the URLs in a database, that's fine, but just imagine you've got a structure like this: