我怎么知道我网站上的哪些静态页面正在访问?

发布于 2025-02-11 13:01:12 字数 67 浏览 1 评论 0原文

我怎么知道我网站上的哪些静态页面正在访问? 通过静态页面,我的意思是pdf。

我使用Apache和PHP。

How can I know which static pages on my site are being visited?
By static pages I mean PDF for the most part.

I use Apache and PHP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜雨飘雪 2025-02-18 13:01:12

您需要查看Apache配置。它将指定您要查看的日志文件的位置。

我相信默认位置是/var/log/apache2一旦那里,您可以使用tail -tail -f access.log 实时监视流量,或者您可以处理logFiles了解资源获得了多少命中。

You need to look at your apache config. It will specify the location of logfiles that you want to look at.

I believe the default location is /var/log/apache2 once there you can monitor traffic in real time with something like tail -f access.log or you can process the logfiles to get an idea of how many hits the resources are getting.

昔日梦未散 2025-02-18 13:01:12

假设您在XAMPP中有(确保正确的cmod写入正确的窗口原因),则可以访问http:// localhost/0/导致服务器已打开,

假设您使用这样的链接来访问每个PDF文件:

http://localhost/0/file1.pdf

http://localhost/0/file2.pdf

假设您的php.ini设置确实允许运行error_log函数

您拥有这些文件
.htaccess

RewriteEngine On
RewriteBase /0/
RewriteRule ^.*\.pdf$ ?countfile=$0 [R=301,L,QSA]

# i'm not so pro with .htaccess so i used work based on
#https://stackoverflow.com/questions/10949685/htaccess-redirect-file-type
#https://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string
#https://stackoverflow.com/questions/20439192/rewrite-url-relative-to-current-directory

index.php

<?php
    isset($_REQUEST['countfile'])and error_log($_REQUEST['countfile']."\r\n",3,'logpdf.txt');
    header('');
    //include($_REQUEST['countfile']);
    header("Content-type:application/pdf");
    header("Content-Disposition:inline;filename='".$_REQUEST['countfile']);
    readfile($_REQUEST['countfile']);
?>

结果

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="CustaRoolez">
<title>just for fun</title>
</head>
<body>
<?php
if(file_exists('logpdf.txt')){
    $files=file('logpdf.txt');
    $statistics=array_count_values($files);
    foreach($statistics as $file => $cnt){
        echo 'the file: '.$file.' was accesed by'.$cnt.' times<br>';
    }
}
?>
</body>
</html>

“ https://www.real-domain-whaterver.extension” rel =“ nofollow noreferrer”> https://www.real-domain-whaterver.extension.extension
.htaccess可能是这样的(您应该设置路线,不是自动的)
因此,对于https://www.real-domain-whaterver.extension/&lt; --------'/'

RewriteEngine On
RewriteBase /
RewriteRule ^.*\.pdf$ ?countfile=$0 [R=301,L,QSA]

请记住,您应该有权在真实的公共领域上写入,您可以修改您
index.php

error_log($_REQUEST['countfile']."\r\n",3,'logpdf.txt'); 

to

error_log($_REQUEST['countfile']."\r\n",3,'/someFOLDERtoLOG/logpdf.txt');

results.php

if(file_exists('logpdf.txt')){
    $files=file('logpdf.txt');

if(file_exists('/someFOLDERtoLOG/logpdf.txt')){
    $files=file('/someFOLDERtoLOG/logpdf.txt');

and

assuming you had in xampp (preferable windows cause for sure cmod write right are on) the folder 0 and you can access http://localhost/0/ cause the server is on ,

assuming you use links like this to acces each pdf file:

http://localhost/0/file1.pdf

http://localhost/0/file2.pdf

assuming your php.ini settings does allow to run error_log function

you have these files
.htaccess

RewriteEngine On
RewriteBase /0/
RewriteRule ^.*\.pdf$ ?countfile=$0 [R=301,L,QSA]

# i'm not so pro with .htaccess so i used work based on
#https://stackoverflow.com/questions/10949685/htaccess-redirect-file-type
#https://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string
#https://stackoverflow.com/questions/20439192/rewrite-url-relative-to-current-directory

index.php

<?php
    isset($_REQUEST['countfile'])and error_log($_REQUEST['countfile']."\r\n",3,'logpdf.txt');
    header('');
    //include($_REQUEST['countfile']);
    header("Content-type:application/pdf");
    header("Content-Disposition:inline;filename='".$_REQUEST['countfile']);
    readfile($_REQUEST['countfile']);
?>

results.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="CustaRoolez">
<title>just for fun</title>
</head>
<body>
<?php
if(file_exists('logpdf.txt')){
    $files=file('logpdf.txt');
    $statistics=array_count_values($files);
    foreach($statistics as $file => $cnt){
        echo 'the file: '.$file.' was accesed by'.$cnt.' times<br>';
    }
}
?>
</body>
</html>

then should be the fastest custom method to logs visits statistics to count pdf access files

on https://www.real-domain-whaterver.extension
.htaccess may be like this (you should set the route ,isn't automaticly)
so for https://www.real-domain-whaterver.extension/ <---- '/' :

RewriteEngine On
RewriteBase /
RewriteRule ^.*\.pdf$ ?countfile=$0 [R=301,L,QSA]

remember you should have right to write so on real public domain you could modify
in index.php

error_log($_REQUEST['countfile']."\r\n",3,'logpdf.txt'); 

to

error_log($_REQUEST['countfile']."\r\n",3,'/someFOLDERtoLOG/logpdf.txt');

and results.php

if(file_exists('logpdf.txt')){
    $files=file('logpdf.txt');

to

if(file_exists('/someFOLDERtoLOG/logpdf.txt')){
    $files=file('/someFOLDERtoLOG/logpdf.txt');

and sure create someFOLDERtoLOG and setting cmod 775 or verify if is already(depend by administrator settings)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文