htaccess允许本地主机的问题

htaccess允许本地主机的问题

本文介绍了的.htaccess允许本地主机的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的情况是......

Here is the situation...

我有计划运行一个cron作业是用来备份我的数据库。的方式,因为安装了PHP,我不得不使用lynx打正在执行备份的PHP脚本。

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.

由于该脚本已在我的public_html文件夹中活着,我想拒绝,除了那些直接来自我的服务器的所有请求(即:本地主机)。另外,我假设我会从未来的IP是127.0.0.1。我不能完全肯定,如果这是真的,但我想不出还有什么我的IP将是这种情况。难道我说得对cron作业运行,并从127.0.0.1击中脚本?

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?

下面是我的.htaccess如下:

Here is what my .htaccess looks like:

order allow,deny
deny from all
allow from 127.0.0.1

这样一来,我不断收到一个403禁止。这就是我想要做的其他人,除了我自己。也许我会对此错误的方式...有谁看到我在做什么错了?

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?

推荐答案

使用顺序倒过来,即:

order deny,allow
deny from all
allow from 127.0.0.1

这篇关于的.htaccess允许本地主机的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:52