3

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.

1
  • 2
    I'm not sure this is possible with just htaccess alone. You will need some form of server-sided language to handle this (something like php). Commented Aug 16, 2017 at 9:36

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.