Forum Moderators: DixonJones

Message Too Old, No Replies

Creative Log Spam Solution

A simple way to make logs private, without passwords

         

jd01

4:04 am on May 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just thought people might like to know the solution I use to make my logs available only to me.

I personally hate typing passwords, so when F-fox was nice enough to allow me to set the user agent to anything I wanted, I just added this to my .htaccess file in my publicly available logs:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^me$ [NC]
RewriteRule . - [F]

Then I added the useragent 'me' to F-fox.

Now all access is denied unless someone happens to set their user agent to 'me' and I simply switch my useragent while I want to look at my logs.

Justin

Obviously 'me' can be easily changed to you.

jatar_k

11:31 pm on May 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



why not just have them outside the root of the site?

and why not just htaccess them if you cant move them?

jd01

12:28 am on May 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't move them, but they are essentially .htaccessed... If you don't have your useragent set to the exact string I have in my .htaccess file, you are forbiden...

I just don't like to type user names and passwords, and thought there might be some other people in the same situation, so now I just add a charatcer or string to my browsers useragent, and I can actually not even change that for other sites, but I am the only one with access to my logs.

EG if my actual .htaccess was:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT}!^Mozilla/5\.0-J$ [NC]
RewriteRule . - [F]

And I add -J to my browser useragent I can browse all day long, check my logs, never change anything, and I am the only one who has access to my log files, because if you do not have your useragent set to the exact string I have in my file, you get a 403.

Just thought some people might find it useful...

Justin

Added: It's also helpful for multiple sites, because rather than having to login in to all of the individual 'stats' I can use the same .htaccess file, and effectively have password protection by useragent rather than formal 'password' files for each one.

moltar

12:54 am on May 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also set IP policies to allow only your IP. If you have a dynamic IP, you can set the whole block.

<Location /stats> 
Order Deny,Allow
Deny from all
Allow from 123.456.789.NN
</Location>

Where NN could be left blank to allow access from the whole range, or you can set it to specific IP address.

Note: I didn't test this, but I am pretty sure it should work.

Check out Apache docs [httpd.apache.org] for more info.