I have a simple ".htaccess" file which needs to do two simple things;

It needs to allow php in normal htm and html files, and use my customized error pages.

The following code is the contents of my entire .httaccess file:

ErrorDocument 400 /error/error400.htm
ErrorDocument 403 /error/error403.htm
ErrorDocument 404 /error/error404.htm
ErrorDocument 500 /error/error500.htm
AddType x-mapp-php4 .html .htm

This all works fine, except, the error pages don't work for incorrect urls in the home directory e.g. "www.example.com/nothing.htm" but incorrect urls after this do work e.g. "www.example.com/file/wrong.html" or "www.example.com/file/another_file/file3/nothing.php" etc.

If I take the "AddType x-mapp-php4 .html .htm" line out - the error pages do function correctly.

I'm not sure if I explained that very well, but if I did - is there anything wrong with the code?

Any help would be appreciated.


Is there anyone who can help me:?:

Am I even in the right forum??

Help.... Please,

Am I even in the right forum??

Not really, but I can't think of a better one...

If you have access to it, is there anything in your Apache error log? That can often be helpful.

I'm assuming you did all the standard stuff, like saving the .htaccess file directly in your public_html or htdocs folder?

You also might want to try:

AddType x-mapp-php4 .html
AddType x-mapp-php4 .htm

instead of putting it on one line...

The error log file will definately be helpful for working out what the problem is... Most virtual hosting plans let you see your part of the server error log, if you're running Apache yourself, it's easy to find ([apache directory]/logs/error_log)

I don't think I have access to the Apache error log :-(

I've taken the AddType x-mapp-php4 .html line out as I don't need it, but still have the AddType x-mapp-php4 .htm , which prevents the error pages working in the home directory.

Is there any other way to get the same effect of AddType x-mapp-php4 .htm , but with some different code?

It just needs to enable php in .htm files.


If you know where PHP is installed; you could try something like:

AddType temp/php .html .htm
Action temp/php /usr/bin/php

where the red path is the absolute path to the PHP executable on your server.

Depending on how PHP is configured to determine the source file; you might even be able to use funky stuff like this to direct a *.htm file to a processing executable:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)\.htm /usr/bin/php [L]

again, you need to know the path to the PHP executable.

With Apache .htaccess files, if there's some 'almost critical' mistake in the file, it can cause other parts of the file to not be applied; so not being able to see the server error log is a bit of a downer.

One thing you might want to try... if you only want the .htm files to be processed as PHP, make the error pages .html (that shouldn't be causing a problem though).

EDIT: Alternatively.....


Try this:

AddHandler x-httpd-php htm

Instead of the AddType.

I don't even know where PHP is installed :sad:

sorry for being a bit useless :rolleyes:

I'm currently only using 1&1's Home package (Linux hosted).

Don't know if that helps....

You can give up on me if you want, but thanks for the help :)