Stop .htaccess blocking cron jobs

Starkers asked:

I have a php script on my site that, when run, changes the ‘Dog of the Day’ on my home page. I have a cron job set up to run the script once a day, and everything works perfectly.

I’ve secured my ‘scripts’ directory with an .htaccess file, because if someone stumbles upon the php script, it’ll be run, causing the ‘Dog of the Day’ to be updated.

ErrorDocument 404 /404.php

order deny,allow
deny from all
allow from

I changed the cron job to run every minute, but the .htaccess is blocking it, despite being whitelisted. I changed to my own ip, and I can access it, so it’s not a problem with syntax.

I’m a graphics designer by trade, and a front-end coder at a push, so keep it simple please!

Thanks a lot!

My answer:

Your script being run from cron is not accessing your own site on the same server via, but by its actual IP address.

For instance, you are probably doing something like:


But doesn’t resolve to localhost, but to your public IP address.

To resolve the issue, whitelist your public IP address instead.

Allow from

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.