使用 htaccess 跟踪访客?
我有一个演示服务器,我在其中放置应用程序的示例,并向潜在客户发送指向这些应用程序的链接。是否可以使用 htaccess 来跟踪访问者,而无需向应用程序本身添加跟踪功能?我感兴趣的数据是:
- 页面访问的日期和时间
- 访问者的IP
- 访问页面的URL
- 引用者
- 帖子并获取(查询字符串)数据(如果有)
I have a demo server where I put samples of my apps, I send potential customers links to those apps. Is it possible to use htaccess to track visitors, without adding tracking capability to the apps themselves? The data I'm interested in are:
- date and time of page visit
- ip of visitor
- url of the page visited
- referrer
- post and get (query string) data if any
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我知道这个线程已经安静了一段时间,但我无法使用 prepend?在所有访问前面添加脚本以跟踪站点/页面访问的指令?
我还没有得到代码(尝试了类似的东西,尽管没有成功),但我使用了 prepend 指令来预先添加一个脚本,该脚本在 gzip 上“切换”所有站点访问。我相信日志也可以实现同样的功能(对于我们这些拥有廉价共享服务器的人来说!)来吧,程序员们,帮我们大家一个忙,揭开这个秘密!
I know this thread has been quiet for a while, but i it not possible to use the prepend?? directive that prepends a script to all visits to track site/page visits ?
I have not got the code (tried something similarthough was not successfull) but I used the prepend directive to prepend a script that "switches" on gzip for all site visits. I am sure the same can be implemented for logs (for those of us with cheap shared servers!) Come on coders, do us all a favour and reveal the secret!
使用谷歌分析的最佳方式。
您将得到您所需要的一切以及更多。
Best way it to use google analytics.
You will get all what you need and much much more.
不,不可能使用 .htaccess 文件,因为它只是一个配置文件,而不是可执行文件。
不过,您可以使用另一种网络服务器功能 - 日志文件。
您要求的所有内容都已存储在访问日志中,几乎与您在此处列出的格式相同。
重要提示:与谷歌分析或任何其他第三方或脚本解决方案不同,网络服务器日志是唯一可靠且准确的跟踪数据来源,包含向您的网站发出的所有请求。
no, that's impossible to use .htaccess file, because it's merely a configuration file, not executable one.
However you can use another web-server capability - log files.
Everything you asking for is already stored in the access log, almost in the same format you listed here.
An important note: unlike google analytics or any other third-party or scripting solution, web-server logs is the only reliable and exact source of tracking data, contains very request been made to your site.
这完全取决于您的网络服务器,它为 htaccess 覆盖提供了哪些选项。
对于 Apache,访问日志会记录您正在查找的内容
http://httpd.apache.org/docs/current/logs.html#访问日志
但无法通过 htaccess 配置。
That entirely depends on your webserver, what options it provides for htaccess overrides.
For Apache, the access log logs what you are looking for
http://httpd.apache.org/docs/current/logs.html#accesslog
but is not configurable via htaccess.