Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
830 views
in Technique[技术] by (71.8m points)

.htaccess allow localhost problem

Here is the situation...

I have a cron job scheduled to run that is used to backup my database. Because of the way php is installed, I'm having to use lynx to hit the php script that is performing the backup.

Because this script has to live within my public_html folder I want to deny all requests except for the ones that come directly from my server (i.e.: localhost). Also, I'm assuming that the ip I'll be coming from is 127.0.0.1. I'm not exactly sure if that's true but I can't think of what else my ip would be in this situation. Am I right about the cron job running and hitting the script from 127.0.0.1?

Here is what my .htaccess looks like:

order allow,deny
deny from all
allow from 127.0.0.1

As a result, I keep getting a 403 Forbidden. Which is what I want to do for everyone else except for myself. Maybe I'm going about this the wrong way... Does anyone see what I'm doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use the order the other way around, ie:

order deny,allow
deny from all
allow from 127.0.0.1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...