duanchongzi9997 2019-04-29 20:47 采纳率: 0%
浏览 99

如何从我的LAMP服务器中访问过的所有页面(包括图像)中获取客户端的IP和主机名?

I'm setting up a web server using apache and want to be able to get client's IP and hostname from any page they visit on the website without having to manually implement logging code in all the files.

I heard about .htaccess RewriteRule and tried that but it just redirects me to a page which logs that info as opposed to staying on the same page and automatically logging it in the background.

RewriteEngine On
RewriteRule ^flower.jpg$ info.php

Say I have a page info.php which logs that info and I have some other pages like welcome.html, flower.jpg, contact.html, game.png

What I expect: Whenever welcome.html, flower.jpg, contact.html or game.png is visited I expect info.php to auto load and log client's IP and hostname in the background.

What actually happened: I got redirected to info.php as opposed to staying on the same page(like flower.jpg as shown in the code)

How can I make sure I load info.php using htaccess in the background without getting redirected to it?

  • 写回答

1条回答 默认 最新

  • doujiao0110 2019-04-30 02:12
    关注

    The Apache access log is at /var/log/apache2/access.log and contains the following for every request:

    • IP
    • Timestamp
    • User agent
    • File
    • Request method
    • Protocol
    • Status code
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件