homepage Welcome to WebmasterWorld Guest from 54.197.211.197
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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

10+ Year Member



 
Msg#: 3391026 posted 9:52 pm on Jul 10, 2007 (gmt 0)

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

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



 
Msg#: 3391026 posted 12:31 am on Jul 11, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3391026 posted 6:36 pm on Jul 29, 2007 (gmt 0)

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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved