Jump to content

Recommended Posts

Here is the .htaccess I have placed in my root directory:

CheckSpelling off
AddType x-mapp-php5 .php

RewriteEngine On
RewriteCond %{HTTP_HOST} !www.asurfc.com
RewriteRule ^.*$     http://www.asurfc.com%{REQUEST_URI} [R]

ErrorDocument 404 http://www.asurfc.com/404.php

 

If a visitor goes to "http://asurfc.com/nowhere.html" or "http://asurfc.com/nowhere/nowhere.php", my custom 404 page gets displayed as expected. But, if a visitor goes to "http://asurfc.com/nowhere.php", my web host's default 404 page gets displayed. It seems my custom 404 page works every time except if the non-existent requested file is a php file in the root directory.

 

Can someone explain why this is happening?

 

 

PS: My web host is 1&1. You can see the problem I have for yourself by visiting the URLs I mentioned above.

I added the following line to my .htaccess file:

#Custom 404 for non existant .php files work around
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^[0-9a-zA-Z_/.-]+\.php$ http://www.asurfc.com/error.php?code=404

 

Everything now works as expected. Any reason the plain "errordocument" declaration wasn't working for non existent php files?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.