Welcome to WebmasterWorld Guest from 54.221.87.97

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

.htaccess "ErrorDocument 404" not work for files ending .PHP

     

jezzer300

9:52 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



Hi,

I can't work out how to stop this, can you help.

I'm hosting with 1and1 and have created an .htaccess file which correctly sends missing page lookups to a specified page, but if the missing page ends with .PHP .PHP5 .PHP4 a generic 1and1 page appears and ignores my ErrorDocument.

Perhaps there needs to be something extra in the .htaccess file?

If you can email me I'll send you a working and failing url so you can see.

....
My .htaccess file below:
#
# .htaccess (site root directory)
# Apache & PHP Settings
#

# Protect files and directories
#order deny,allow
#deny from all

# Options
#Options FollowSymLinks

# Re-direct Site Errors
ErrorDocument 400 /error.php?errordoc=400
ErrorDocument 403 /error.php?errordoc=403
ErrorDocument 404 /error.php?errordoc=404
ErrorDocument 500 /error.php?errordoc=500

# Tell 1and1 to use PHP5 by default
AddType x-mapp-php5 .php

# Save Bandwidth
# 1and1 not functional

#<ifModule mod_php4.c>
#php_value zlib.output_compression 16386
#</ifModule>

# Rewrite URLS
# note: [NC] nocase (case insensitive)
# prefix z makes the items more unique

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^zcat(.*)_p(.*)_size(.*)$ item_cat.php?cat=$1&page=$2&image_size=$3
RewriteRule ^zcat(.*)_p(.*)$ item_cat.php?cat=$1&page=$2
RewriteRule ^zcat(.*)$ item_cat.php?cat=$1
RewriteRule ^zinfo(.*)_cat(.*)$ item_info.php?item=$1&cat=$2
RewriteRule ^zinfo(.*)$ item_info.php?item=$1

RewriteRule ^friend$ index?refer=friend
</IfModule>

whoisgregg

12:31 am on Jul 11, 2007 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Contact your hosting provider. The .htaccess files don't automatically allow all things to be overridden and it sounds like it's going to be something they need to fix.

pseal

6:36 pm on Jul 29, 2007 (gmt 0)

5+ Year Member



My friend Max and I just had this problem, and he solved it as follows:

RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
# Rewrite missing cgi files to known non-existent html page to force proper 404 error handling
RewriteRule \.(php¦cgi)$ /force_404_error.html [L]