我没有代码向您展示,因为我的都没有真正工作,但我需要知道如何限制位于根目录(root/upload/
)中的upload
文件夹中的文件(jpgs
和php
)。我想这样做,所以如果你去mysite.com/upload/
那么什么都没有出现,但我希望我的index.php
位于我的根(root/index.php
)中,以便能够访问受限制upload/
文件夹中的jpgs和php。任何帮助将不胜感激!
index.php
/uploads/
/uploads/temp/
/uploads/temp/upload.php
/uploads/temp/.htaccess
/uploads/temp/(multiple jpeg files)
我想要它,这样如果你去 mysite.com/uploads/temp,那么什么都不会弹出,但我希望index.php
能够打电话给images
并upload.php
这样的东西在你的.htaccess
中应该就足够了。只需将其放入upload
目录中即可。
# Refuse direct access to all files
Order deny,allow
Deny from all
Allow from 127.0.0.1
将此代码放在uploads/.htaccess
文件中:
RewriteEngine On
# block if referrer is not your domain's index.php
RewriteCond %{HTTP_REFERER} !^http://(www'.)?yourdomain'.com/index'.php [NC]
RewriteRule ^ - [F]