Prevent Directory Listing防止目录列表
January 31st, 2007 · by David Bradley 2007年1月31日,大卫布拉德利
If you followed my advice to move from Blogspot to your own domain hosted Wordpress blog, then you may have noticed (depending on how your new host server is set up) that opening certain directories produces not the page you were expecting, but a listing of the contents of that directory.如果你遵循我的意见,提出从BlogSpot的,以您自己的网域主办的WordPress所博客,那么您可能已经注意到, (取决于如何您的新主机服务器是成立)表示,开放某些目录产生的不是网页中,您的预期,但上市该目录的内容。
Now, that’s not usually a problem for most users, it just generates an ugly directory that makes your site look unprofessional.现在,这通常不是问题,对于大多数用户来说,它只是产生一个丑陋的目录,使您的网站看看专业。 However, it can expose file and folder names on your server that you don’t want visitors to browse and read.不过,它可以揭露档案和资料夹名称在您的服务器上,您不希望访客浏览和阅读。
There is a very quick fix for this.有一个很快速修复此。
Open your .htaccess file (usually in the root folder or public_html)打开你的。 htaccess的文件(通常是在根文件夹或public_html )
near the top simply enter the following line of code and save the file.上方附近只需输入以下代码行和储存档案。
IndexIgnore * indexignore *
Now, when you try to open that “directory listing” it won’t display the folder’s contents.现在,当您尝试打开“目录清单”将不会显示该文件夹的内容。
If you don’t want to block all browsing, just gifs and jpgs or zip files for instance, then use the following syntax instead:如果您不想阻止所有浏览,只是gifs和jpgs或ZIP文件,例如,然后使用下面的语法,而是:
IndexIgnore *.gif *.jpg indexignore *.的GIF *. JPG格式
IndexIgnore *.zip indexignore *.邮编
IndexIgnore *.mp3 indexignore *.的MP3
(You get the picture) (您了解图片)
Conversely, you might actually want to allow browsing of directories, but it’s disabled on your host by default.反之,你实际上可能要允许浏览的目录,但它的残疾人士对您的主机默认情况下。 Again, it’sa .htaccess issue, see if IndexIgnore is already in there and delete it, if not enter this line instead:再次,这是。 htaccess的问题,看看是否indexignore是已经在那里并删除它,如果不是进入这条线,而是:
Options +Indexes选项+指标
That opens up directory listing for the root folder (and/or any other folders in which you have a .htaccess file).开辟的目录清单,为根文件夹(和/或任何其他文件夹中,您有一个。 htaccess的档案) 。
However, even that is not a particularly elegant solution.不过,即使这不是一个特别优雅的解决办法。 What I was finding till I did the following tweak was that Wordpress was displaying the contents of the feed folder rather than displaying the feed.我是发现到我以下的调整是在WordPress是显示的内容,该饲料的文件夹,而非展示的饲料。 So, here’s the solution that makes a click on that directory do the right thing.因此,这里的解决办法作出了按一下那个目录做正确的事。 Open CPanel and navigate to your Index Manager.开放的cPanel和浏览到您的经理人指数。 Click the feed folder (or whichever folder you want to block directory listing of) and choose “No Indexes”.按饲料的文件夹(或哪一个文件夹中您想拦截的目录列表)并选择“没有指标” 。 That got my rss feed for this site working properly, and if applied to other folders too prevents directory listings and spawns a 403 error page, which can be customized.这叫起我的RSS馈送此网站的正常工作产生影响,如果应用到其他文件夹也可以防止目录列表和会产生1 403错误页面,可以定制。 More on custom 404 and 403 pages another time更多的自定义404和403页的另一个时间

















0 responses so far ↓ 0反应到目前为止↓
Got something to say?得到的东西说什么呢? Start a comment thread here.启动一个线程在这里发表评论。 Top commentators get a FREE link on the homepage!顶端评论家立即获得免费的链接的网页!
Leave a Comment留下意见