我希望 index.php 访问受 .htaccess 限制的文件


I want index.php to access files restricted by .htaccess

我没有代码向您展示,因为我的都没有真正工作,但我需要知道如何限制位于根目录(root/upload/)中的upload文件夹中的文件(jpgsphp)。我想这样做,所以如果你去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能够打电话给imagesupload.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]