如何使Apache停止记录我的Urls

陈洪武

我有一个Web应用程序。

对我的应用程序的所有请求都将传递到Root / index.php。例:

1. http://myapp.com/?call=phpfile1.processSomething&param1=x&param2=y
2. http://myapp.com/?call=phpfile2.processSomethingElse
3. http://myapp.com/?call=phpfile3.methodXYZ...

我还有另一个应用程序(WindowServices),它将在我的WebApp中调用某些Urls(全天:v)。当我打开access.log时,它是这样的:

[2018-08-07 12:23:43] "GET /?call=phpfile1.processSomething&module=5 HTTP/1.1" 200 16
[2018-08-07 12:23:43] "GET /?call=phpfile2.processSomethingElse&module=2 HTTP/1.1" 200 16
[2018-08-07 12:23:43] "GET /?call=phpfile1.processSomething&module=0 HTTP/1.1" 200 16
[2018-08-07 12:23:43] "GET /?call=phpfile1.processSomething&module=7 HTTP/1.1" 200 16
[2018-08-07 12:23:43] "GET /?call=phpfile2.processSomethingElse&module=4 HTTP/1.1" 200 16
[2018-08-07 12:23:43] "GET /?call=phpfile2.processSomethingElse&module=3 HTTP/1.1" 200 16

并且... access.log文件随着时间的推移将是大文件。

因此,我不希望Apache记录Urls:

1./?call=phpfile1.processSomething
2./?call=phpfile2.processSomethingElse

我在vhost文件中设置了一些配置,如下所示:

<VirtualHost *:80>
    DocumentRoot "D:\MyFolderApp"
   <Directory "D:\MyFolderApp">
         AllowOverride All
         Order allow,deny
         Allow from all
         DirectoryIndex index.php index.html
         Require all granted         
   </Directory>
   ServerName myapp.com
   SetEnvIf Request_URI "^/?call=phpfile1.processSomething" dontlog
   SetEnvIf Request_URI "^/?call=phpfile2.processSomethingElse" dontlog
   LogFormat "%h %l %u %t \"%r\" %>s %b" common
   CustomLog "logs/myapp.com-access.log" common env=!dontlog
</VirtualHost>

但是Apache仍然为这些Urls编写日志!!!

所以,任何人都可以帮助我!谢谢!

陈洪武

感谢尼克和塔伦。我解决了我的问题。在我的.htaccess文件中,添加一些配置:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^automate/phpfile1/(.*) ?call=phpfile1. processSomething&module=$1
    RewriteRule ^automate/phpfile2/(.*) ?call=phpfile2.processSomethingElse&module=$1
</IfModule>

在我的httpd-vhosts.conf文件中,设置如下:

SetEnvIf Request_URI "^/automate/phpfile1/"  dontlog
SetEnvIf Request_URI "^/automate/phpfile2/"  dontlog
CustomLog "logs/myapp.com-access.log" combined  env=!dontlog

因此,apache不会记录Uris:D

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章