简体   繁体   English

如果来自同一IP,则将网站访问者重定向到新页面

[英]Redirect website visitor to new page if from same IP

I need to redirect a website visitor to a different file on my site if they come from the same IP within the last 24 hours. 如果过去24小时内来自同一IP的网站访问者来自同一IP,则需要将其重定向到我网站上的其他文件。

For example user 1 visits my website from IP 34.56.22.222 and he goes right to the index.php (home page). 例如,用户1从IP 34.56.22.222访问我的网站,然后直接转到index.php(主页)。

But then he refreshes the page or comes back to the site within a 24 hour period. 但是随后,他刷新了页面或在24小时内返回了该网站。 In that case I'd like him to be redirected to index1.php. 在那种情况下,我希望将他重定向到index1.php。

Is there anyway this can be done with .htaccess? 无论如何,这可以用.htaccess完成吗?

您可以在访问者网站上设置一个24小时的cookie,并检查请求是否存在cookie,然后将其重定向到index1.php(这将在客户端浏览器级别而不是ip级别上进行检查),如果要进行检查在ip级别上,则应该在redis或任何需要设置TTL 24小时的位置设置标志值,每当有新请求出现时,请检查客户端ip的标志,如果存在则重定向到index1.php,我不知道有什么办法从.htaccess做到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM