使用的.htaccess,prevent用户访问资源目录,但允许源$ C ​​$ C接入资源 [英] Using .htaccess, prevent users from accessing resource directories, and yet allow the sourcecode access resources

查看:237
本文介绍了使用的.htaccess,prevent用户访问资源目录,但允许源$ C ​​$ C接入资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的问题还不清楚,但我不是很了的行话道歉。通过资源目录我的意思是我的CSS,PHP脚本,图片,JavaScript等。

Apologies if my question is unclear, but I'm not quite up with the jargon. By 'resource directories' I mean my css, php scripts, images, javascript ect.

我包含我的图片目录中使用.htaccess文件

I used an .htaccess file in my images directory that contained

deny from all

做到这一点。虽然这$ P $打字www.example.com/images到他们的浏览器,并访问我的图片目录pvented人,停止图像出现在我的网站。

to do this. Though this prevented people from typing "www.example.com/images" into their browser and accessing my images directory, the images stopped appearing on my website.

我想这是因为.htaccess文件甚至拒绝访问该图片我的源$ C ​​$ C。我怎样才能让我的源$ C ​​$ C访问的目录?我也有一个cron作业运行PHP脚本,每一个夜晚。该cron作业也需要允许访问scripts目录。

I assume this is because the .htaccess file is even denying my source code from accessing the images. How can I let my source code access directories? I also have a cron job running a php script every night. The cron job also needs to be allowed to access the scripts directory.

此外,使用.htaccess文件即使是最好的办法,以确保一个网站?

Also, is using .htaccess files even the best way to secure a site?

推荐答案

要prevent有人来查看您的图片目录,你需要禁止目录列表。 <一href="http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-$p$pvent-htaccess-directory-listing/">http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-$p$pvent-htaccess-directory-listing/

To prevent someone to view your images directory, you need to disallow Directory Listing. http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-prevent-htaccess-directory-listing/

您无法使用所有拒绝,因为没有什么可以从Web浏览器的目录加载,所以你的图片,你对你的网站将不会加载加载无论是。

You cannot use deny from all, because nothing can be loaded from that directory from a web browser, so your images which you load with on your website won't load either.

选项-Indexes 将禁止人们在图像目录中列出文件。请参阅<一href="http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-$p$pvent-htaccess-directory-listing/">http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-$p$pvent-htaccess-directory-listing/

Options -Indexes will disallow people to list files in your images directory. Please see http://viralpatel.net/blogs/htaccess-directory-listing-enable-disable-allow-deny-prevent-htaccess-directory-listing/

有关由人应该不是你可以使用身份验证谁正在查看安全数据。您可以设置与htaccess的登录场,或脚本之一,例如PHP或者Python。

For securing data from being viewed by people who shouldn't you can use a authentication. You can setup a login field with htaccess, or script one with, for example PHP or python.

登录与htaccess的脚本: 脚本: <一href="http://www.htaccesstools.com/htpasswd-generator/">http://www.htaccesstools.com/htpasswd-generator/ 密码文件: <一href="http://www.htaccesstools.com/htaccess-authentication/">http://www.htaccesstools.com/htaccess-authentication/

Login script with htaccess: Script: http://www.htaccesstools.com/htpasswd-generator/ Password file: http://www.htaccesstools.com/htaccess-authentication/

这篇关于使用的.htaccess,prevent用户访问资源目录,但允许源$ C ​​$ C接入资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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