Akhilesh Kumar
Akhilesh Kumar

Reputation: 919

Create log file using htaccess

I am trying to create a log file by using a .htaccess script. I have a image directory in which I want to place the .htaccess file which will write all file names which is accessed from this image folder.

I now need to create a log inside image folder.

I tried with RewriteLog but it's not working for me. I am using Apache version 2.4.

Upvotes: 3

Views: 3138

Answers (1)

Akhilesh Kumar
Akhilesh Kumar

Reputation: 919

After going through Apache documentation for log creation, I found that Apache not allowed to write code for log creation in .htaccess file. We need to write code in httpd.conf file.

Source

My code to write log file for all images in httpd.conf file is:

SetEnvIf Request_URI "(\.gif|\.png|\.jpg|\.jpeg|\.JPEG|\.JPG|\.PNG|\.GIF|\.JFIF|\.TIFF|\.BMP)$" image-request=log
CustomLog logs/unwanted-requests.log common env=image-request

Upvotes: 5

Related Questions