Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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