Cronjob with password protected site (.htaccess)

有些话、适合烂在心里 提交于 2020-01-12 18:47:17

问题


I want to create a cronjob that every X time goes to open a webpage.

This webpage is password protected by .htaccess (user=admin, passwor=pass). The instruction I give is the following:

wget --user=admin --password='pass' http://www.mywebsite.com/test.php

But cron gives me the following error:

--2012-05-02 10:14:01--  http://www.mywebsite.com/test.php
Resolving www.mywebsite.com... IP
Connecting to www.mywebsite.com|IP|:80... connected.
HTTP request sent, awaiting response... 401 Authorization Required
Reusing existing connection to www.mywebsite.com:80.
HTTP request sent, awaiting response... 403 Forbidden
2012-05-02 10:14:01 ERROR 403: Forbidden.

I have also tried doing:

wget admin:pass@http://www.mywebsite.com/test.php

but with similar errors. How can I solve? Thank you in advance for your help.


回答1:


You are making a small mistake.

keep the http:// before the url.

You have

admin:pass@http://www.mywebsite.com/test.php

Change it to

http://admin:pass@www.mywebsite.com/test.php

Hope that works.




回答2:


wget --user admin --password pass http://www.mywebsite.com/test.php

Opens every minutes a website with a htaccess password

*/1 * * * *  wget -O /dev/null --user admin --password pass "http://www.mywebsite.com/test.php" > /dev/null 2>&1



回答3:


Add auth parameter to url. This works for me when call url directly.

http://yoururl.ext?auth=id:psw

I don't know how much secure it is...



来源:https://stackoverflow.com/questions/10410140/cronjob-with-password-protected-site-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!