1

I have added

Order Deny,Allow
Deny from all
allow from *my ip*

to my htaccess file but now when I use a function like getimagesize, I get an error while trying to retrieve the data from a local file on the server.

Error: [function.getimagesize]: failed to open stream: Redirection limit reached

When I remove the lines in htaccess it works. I also tried adding "allow from localhost" and "allow from 127.0.0.1" but no avail.

2 Answers 2

3

Since it's local, why are you using an HTTP request to fetch the image details? A local path would bypass the webserver and make this a moot question. It would also be far more efficient, since you're not creating/request/receiving/tearingdown an entire HTTP request sequence.

Instead of

 file_get_contents('http://yourserver.com/url/to/image.jpg');

use

 file_get_contents('/file/system/path/to/image.jpg');
0

Your htaccess seems correct but it doesn't guarantee that Apache is honoring it. Check Apache's error_log for more details on why it's denying access and also if you're allowed to override these settings.

If these files are local, you should probably specify the local path instead of going through HTTP.

You must log in to answer this question.