如何prevent目录访问,并显示在PHP禁止错误 [英] how to prevent directory access and show forbidden error in php

查看:127
本文介绍了如何prevent目录访问,并显示在PHP禁止错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我是新来的.htaccess,我想知道如何通过我的文件夹,例如URL中使用.htacces至prevent直接访问本地主机/ mycart /影像/或本地主机/ mycart / CSS应该显示禁止讯息。


  2. 目前我已经把我的index.php网站的每一个文件夹中,并呼应的消息是好办法做到这一点。


  3. 当我进入我的网站像www.mycart /的index.php / CSS或www.mycart / index.php文件/图像显示它的网站没有图像和CSS为什么和如何解决它?



解决方案

我用

 #禁止目录浏览
选项​​-Indexes

相反,要启用目录浏览,请使用以下指令:

 #允许目录浏览
选项​​+指标

同样,此规则将prevent服务器从列出目录内容:

 #prevent文件夹列表;
IndexIgnore *

和,最后,IndexIgnore指令可用于prevent选择文件类型的显示:

 #prevent选择文件类型的显示
IndexIgnore * .WMV * .MP4 * .AVI * .etc

礼貌从:从的 prevent未经授权目录浏览 = HTTP://perishable$p$pss.com/$p$pss/2006/01/10/stupid-htaccess-tricks/>愚蠢的.htaccess技巧

它也包含在的.htaccess 用于安全性和性能增强许多其他有用的命令。

  1. I am new to .htaccess, i want to know how to use .htacces to prevent direct access via url of my folder e.g. localhost/mycart/images/ OR localhost/mycart/css should show forbidden message.

  2. currently i've put index.php in every folder of my website and echo the messages is it good way to do it.

  3. when i access my website like www.mycart/index.php/css or www.mycart/index.php/images it show website without images and css why and how to fix it?

解决方案

I have used

# disable directory browsing
Options -Indexes

Conversely, to enable directory browsing, use the following directive:

# enable directory browsing
Options +Indexes

Likewise, this rule will prevent the server from listing directory contents:

# prevent folder listing
IndexIgnore *

And, finally, the IndexIgnore directive may be used to prevent the display of select file types:

# prevent display of select file types
IndexIgnore *.wmv *.mp4 *.avi *.etc

Courtesy From: Prevent Unauthorized Directory Browsing from Stupid HTACCESS Tricks.

It also contains many other useful commands to be used in .htaccess for security and performance enhancement.

这篇关于如何prevent目录访问,并显示在PHP禁止错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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