.htaccess 允许本地主机问题 [英] .htaccess allow localhost problem

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

问题描述

情况是这样的...

我有一个计划运行的 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 文件夹中,所以我想拒绝所有请求,除了直接来自我的服务器(即:localhost)的请求.另外,我假设我将来自的 IP 是 127.0.0.1.我不确定这是否属实,但我想不出在这种情况下我的 ip 还会是什么.我对从 127.0.0.1 运行并点击脚本的 cron 作业是否正确?

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 Forbidden.这就是我想为除了我自己以外的所有人做的事情.也许我用错误的方式解决这个问题......有没有人看到我做错了什么?

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 允许本地主机问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆