从 localhost 以外的其他地址访问 Symfony/web/config.php?

Access Symfony/web/config.php from other address than localhost?(从 localhost 以外的其他地址访问 Symfony/web/config.php?)
本文介绍了从 localhost 以外的其他地址访问 Symfony/web/config.php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在测试不同的 PHP 框架,以了解我将在下一个项目中使用的女巫.我刚刚在我的网络服务器上安装了 Symfony2.当试图访问 Symfony/web/config.php 文件时,Symfony 阻止该文件被 localhost 以外的任何人编辑.我的服务器上没有 gui,所以如果没有浏览器,可视化配置将毫无用处.

I'm currently testing different PHP frameworks to see witch on my going to use for my next project. I just installed Symfony2 on my web server. When trying to access the Symfony/web/config.php file, Symfony blocks this file from being edited by any other than localhost. Of cures there is no gui on my server, so a visual config is quite usless without a browser.

有没有办法从 loclhost 以外的任何其他地址调用访问 Symfony/web/config.php 文件?

Is there a way to call access the Symfony/web/config.php file from any other address than loclhost?

推荐答案

您可以将自己的主机添加到该配置中,以便您可以使用浏览器打开它.

You can add your own host to that configuration so you can open it with your browser.

为此,请添加您的主机(即您的公共 WAN IP,例如 你可以google一下)到config.php 文件.这是顶部的主机名数组,请参阅 'myvery own ip' 示例条目:

To do so, add your host (that is your public WAN IP, e.g. you can google it) into the config.php file. It's the array of hostnames on top, see the 'my very own ip' example entry:

if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
    'my very own ip',
))) {
    header('HTTP/1.0 403 Forbidden');
    die('This script is only accessible from localhost.');
}

然后您应该能够访问服务器上的脚本.

You should then be able to access the script on your server.

这篇关于从 localhost 以外的其他地址访问 Symfony/web/config.php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)