I'm trying to set up a cron job to run this command every day:
wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
The website example.com is located on the same server I'm running the cron job from. But I keep getting an error 403 in my logs:
"GET /wp-cron.php?doing_wp_cron HTTP/1.1" 403 428 "-" "Wget/1.17.1 (linux-gnu)"
When I try to access the same url from my browser it works though:
"GET /wp-cron.php?doing_wp_cron HTTP/1.1" 200 304 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
So I guess there is something blocking requests from my own server in my apache2.conf (or .htaccess file), but I have no idea what to look for. Any idea what line could be responsible of this?
There was a rewrite condition in my .htaccess blocking some user agents, I guess including empty user agents. Adding
--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0"
did the trick:See also: https://unix.stackexchange.com/questions/139698/why-would-curl-and-wget-result-in-a-403-forbidden