Heim  >  Artikel  >  Backend-Entwicklung  >  url栏输入项目子目录地址列出目录列表问题?

url栏输入项目子目录地址列出目录列表问题?

WBOY
WBOYOriginal
2016-08-08 09:06:501057Durchsuche

用的是CI框架,请问怎么设置禁止访问子目录?

url栏输入项目子目录地址列出目录列表问题?

回复内容:

用的是CI框架,请问怎么设置禁止访问子目录?

url栏输入项目子目录地址列出目录列表问题?

nginx/Apache 配置单一入口

httpd.conf

Options Indexes FollowSymLinks

修改为:

Options FollowSymLinks

与框架无关

可能你没理解单一入口的意思,主要是防止越权访问。例如:你的根目录为
index.php //程序入口
admin //假设是后台文件
----index.php
----left.php
----main.php
这个时候就存在一个问题,如果别人知道你的路径 就可以直接访问admin/index.php 就可以看到后台页面的内容。如何解决这个问题呢?那么就在根目录的

<code>index.php

define ("ROUTE", TRUE );
$dos = array ('index','left','main');
(!empty($do)&& in_array($do, $dos)) and $do or $do='index'; 

admin/index.php

defined ( 'ROUTE' ) or exit ( 'Access Denied' );

这样 但别人直接访问admin/index.php的时候就可以起到禁止访问的效果

所有访问都必须通过你的url规则来访问
</code>

Apache:
进入apache的配置文件 httpd.conf 找到:

<code>Options Indexes FollowSymLinks
修改为:
Options FollowSymLinks</code>

Indexes标识当前目录没有index.html就显示目录结构

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn