Forum Moderators: phranque

Message Too Old, No Replies

Getting 500 error when trying to access a directory on a site

         

Marcia

2:31 am on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no reason for it, the /directories/ that are part of the main site content aren't any problem. But when trying to connect to /another/directory/ I'm getting that 500, that an error has occurred. I really need to access it, it's for sites under construction.

There are no scripts, permissions or restrictions being used, it's just normal virtual hosting on Linux/Apache. What could be the problem?

jdMorgan

2:53 am on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Marcia,

Does your error log contain an entry when this happens? Without further detail, it's pretty hard to tell, other than to say you've put some bad code in your .htaccess file or your host has messed up your server config in httpd.conf.

If this used to work, and suddenly stopped working, and you've made no changes to your .htaccess files or scripts, then contact them and tell them that whatever they've done in the period since it last worked has broken your site.

Jim

Marcia

4:23 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably something I did. With just the /directoryname/ I got the error, and also with index.htm - but after changing that to index.html it accessed the file with no error.

This is what I did

AddType application/x-httpd-php .html .php .htm
AddHandler application/x-httpd-php .html .php

And I did this, too

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://example.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.example.com$ [NC]
RewriteRule .*\.(jpg¦jpeg¦gif¦png¦bmp)$ - [F,NC]

Added:

Changed the first to this and stopped getting the error:

AddType application/x-httpd-php .html .php .htm
AddHandler application/x-httpd-php .html .php .htm

I'm not sure if both of those are needed; I just want to be able to use php includes on regular html pages.

jdMorgan

6:14 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Marcia,

Probably something to do with the default index page handling... I dunno.

You can get rid of three unnecessary lines and unneeded overhead in your code if you'd like to speed things up a bit:


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteRule \.(jpe?g¦gif¦png¦bmp)$ - [NC,F]

This has the exact same functionality as what you posted, it's just a lot more compact. Change the broken pipe characters back to solid ones before trying to use it, though.

Also, I'd strongly recommend that you consider what happens to AOL users and other users whose ISPs block the referrer data or use caching proxies -- and a lot of them do. These visitors will see broken images on your site.

Unfortunately, the fix is to allow blank referrers, and some of those will be hotlinkers. So this is a choice everyone has to make for themselves.

You can fix the broken image problem by adding the line

 RewriteCond %{HTTP_REFERER} . 

ahead of the RewriteCond in the code above.

Jim