On an Apache host, I have a folder called /thumbs with a program in it called program.php that I will use to create thumbnails.

There is a .htaccess file that contains the following lines:

options -indexes
errordocument 404 program.php

What should happen is that when I call /thumbs/image1.jpg, program.php should be executed.

What actually happens is that the browser just echoes the name of the program. Calling /thumbs/image1.jpg results in the browser showing:

program.php

and no code is executed.

I have used this technique on many other sites and it has worked, but not this time.

Anybody know why this might be the case?

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

The ErrorDocument directive can be used several ways, depending on the syntax. To execute a file the way you want, you must use the full path relative to the DocumentRoot, preceded with a /. Otherwise, it's taken to be a literal message to be displayed, which is what is happening for you.

Try this:

 ErrorDocument 404 /thumbs/program.php

More info here: http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.