怎样才能文档根目录的Web服务器的行为改变? [英] How can the document root be changed in web server behavior?

查看:553
本文介绍了怎样才能文档根目录的Web服务器的行为改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有改变相对文档根目录额外的安全性的一种方式。我会尝试通过以下的例子来解释一下:

I'd like to know if there is a way of changing the relative document root for extra security. I'll try to explain myself through the following example:

/root
    /app
    /public

说,一个 www.example.com 请求到web服务器将指向<为code>根文件夹中。

通过位于所述文件夹中的的.htaccess 文件,我在想,如果有一个配置举例来说,这将使服务器指向<为code>公共文件夹而不是,因此有任何远程路径总是相对称公共文件夹中。< BR>
在这种情况下, www.example.com/app <​​/ code>将要求里面的应用文件夹公共,而不是应用文件夹中的,让后者无法访问从远程URL请求。结果
以同样的方式, www.example.com/public 将要求我们的内部根<$ c进行公共文件夹$ C>公共
文件夹等等。

Say an www.example.com request to the web server would point to the root folder.
I was wondering if there was a configuration, for instance through an .htaccess file located in said root folder, that would make the server point to the public folder instead, therefore having any remote paths always be relative to said public folder.
In this instance, www.example.com/app would request an app folder inside of public, instead of an app folder inside of root, leaving the latter to be inaccessible from a remote url request.
In the same manner, www.example.com/public would request a public folder inside of our root public folder and so forth.

我读过的各种主题如这个提及使用自定义的.htaccess 的配置来实现类似的东西,但它需要请求URL中表示文件中手动配置,而我的本意是,它无需进一步配置不工作无论你在哪里托管应用程序。
另一种可能的解决方案我已经看到了正在做一个硬通过的.htaccess 文件,它实际上并没有解决任何问题重定向。

I've read various topics like this one that mention using a custom .htaccess configuration to achieve something similar, but it requires the manual configuration of the request url in said file, while my intention is for it to work without further configuration no matter where you host the application. Another possible solution I've seen is doing a hard redirect through the .htaccess file, which does not solve anything actually.

随意编辑这个职位,因为我可能有一个困难时期试图使对方了解我的观点。

Feel free to edit this post as I might have had a hard time trying to get my point across.

推荐答案

我建议你点你的服务器公用文件夹无论如何,因为它是更安全的,你可以看到所有框架的行为方式相同,他们都有一个公共文件夹所在的服务器指向。

I suggest that you point your server to the public folder anyhow, as it is much more secure, you could see that all frameworks behave the same way, they all have a "public" folder where the server points to.

在公用文件夹你进入一个点到你的脚本,如

In the public folder you have one point of entry to your scripts, like

index.php

和从此项你将与你的应用程序进行通信。

and from this entry you will communicate with your application.

当然,你仍然可以工作,你要求的方式,将工作的伟大,但谁知道也许你会错过一些东西,有人可以访问和查看您的内部文件。

Of course you can still work the way you requested, and it will work great, but who knows maybe you will miss something and someone could access and view your "inner" files.

这篇关于怎样才能文档根目录的Web服务器的行为改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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