EasyPHP: Access forbidden! on images

Running the EasyPHP WAMP server I found that my local website was not displaying images, and pointing directly to an image (jpg or gif) was displaying the server error “Access forbidden!”. The solution…

I had forgotten that my directory includes an htaccess file containing anti-leech code. It specifies that if the domain hosting the site is not the referring domain, then block images.

Since EasyPHP was running as “localhost” with an IP address of “127.0.0.1”, then they were being blocked too.

The simple solution was to allow localhost to access the images too. Here are the lines, with the addition lines in bold:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !mydomain.co.uk/.*$ [NC]
RewriteCond %{HTTP_REFERER} !127.0.0.1/.*$ [NC]
RewriteCond %{HTTP_REFERER} !localhost/.*$ [NC]
RewriteRule \.(gif|jpg|js|css|mp3|wma)$ - [F]