# custom error pages don't work for .php extensions



## The Infinity (May 12, 2005)

I was wondering how to get my error pages to work when there is a .php extension. For example if I type in:

http://site.com/sdgfsdfs

my custom error pages in my .htaccess work, but when I type in

http://site.com/sdgfsdfs.php

It refers it to the default error 404 page that came with my hosting. how can I get my pages to come up for all extensions?


----------



## namenotfound (Apr 30, 2005)

I'm getting the same "error page" for both 
I see no difference 



> The page cannot be found
> The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
> 
> Please try the following:
> ...


----------



## Eriksrocks (Aug 7, 2005)

Same here.


----------



## Eriksrocks (Aug 7, 2005)

If found this in the 1&1 help docs:


> Using a .htaccess file does not work for php files. If you want these
> errors to work for php files too, then use the process below.


The "process below" being:


> *By adding this piece of code in the .htaccess file*
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> ...


----------



## The Infinity (May 12, 2005)

Awsome I think that did the trick


----------



## The Infinity (May 12, 2005)

Is it also possible to disable someone being able to type in ftp://mysite.com and when the FTP login and password box comes up.

Can you disable that with .htaccess also?


----------



## Eriksrocks (Aug 7, 2005)

Sorry, I have no clue.


----------



## The Infinity (May 12, 2005)

Ok false alarm 

I thought it was working. Now when I type http://www.mysite.com/dsfds.php it works since that page does not exist, but when I type in http://www.mysite.com/index I get the default 404 again, not my custom one. So if the page exist but its the wrong at the end extension I get the default 404 error from my web hosting.

If it helps here is my .htaccess file:


```
<Files .htaccess>

order allow,deny

deny from all

</Files>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocs/error404.htm
```
I'm new at the .htaccess thing so I may have made a mistake.


----------



## namenotfound (Apr 30, 2005)

When someone tries to view your .htaccess file, by default they should get a 403. I'm pretty sure you don't need to add a denial to it in .htaccess, in other words this I don't think this is needed:

<Files .htaccess>
order allow,deny
deny from all
</Files>


----------



## Eriksrocks (Aug 7, 2005)

Do you have a folder named index?

Try something: Move error404.html to the root directory so it would be at softhardware.net/error404.html so it would look like:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error404.htm
```
If that doesn't work...

Try adding some stuff below what you already have so your .htaccess would look like this:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error404.htm

ErrorDocument 404 http://www.softhardware.net/error404.html
```
That might take care of the problem. If it doesn't, you might want to contact 1&1 support because I think it might have something to do with 1&1's redirection system. They try to make your site user friendly by redirecting you to common URLs if the page isn't found. e.g of you type in index.php but it doesn't exist and there is a page named index1.php, it will automatically redirect you there.


----------



## The Infinity (May 12, 2005)

Eriksrocks said:


> Do you have a folder named index?
> 
> Try something: Move error404.html to the root directory so it would be at softhardware.net/error404.html so it would look like:
> 
> ...


Hey Erik,

Well I got it to work, but how it happened is very weird. I kept changing the htaccess over ad over, and I kept getting a 500 error, so I just moved all my custom error pages:

error404.html
error500.html
error400.html

etc.

Once I moved those into the root directory everything worked. I even took out all the things I put in my htaccess and it still worked. So I'm not really sure how this is possible, but everything works accordingly. 

I wish there was a way to move them out of the root directory and still work, but I guess I can't do that. Oh well, thanks Erik


----------



## Eriksrocks (Aug 7, 2005)

It's another way to do it. See this page:
http://faq.1and1.com/scripting_languages_supported/configuring_apache_server_using_htaccess/2.html


----------



## namenotfound (Apr 30, 2005)

1and1 has a screwy server 



> 4. Test it out. Go to http://www.your_domain.com/anything_you_want.html
> Using a .htaccess file does not work for php files. If you want these
> errors to work for php files too, then use the process below.


On my host I can use whatever the heck I want for the error page extension

All I have to add is:
ErrorDocument 404 http://www.your_domain.com/404.php

And it works. I could even make up an extension such as:
ErrorDocument 404 http://www.your_domain.com/404.error

And that works too.

1and1 seems crazy


----------



## Eriksrocks (Aug 7, 2005)

No, they meant that if a PHP file does not exist (i.e. you look for dfjajklfdjak.php), the custom 404 error page won't be displayed, not that the extension of the actual error page matters. I don't believe that happens just with 1&1.


----------



## namenotfound (Apr 30, 2005)

1, oooooh ok, well 1and1 needs to make that clear 

2, 1and1 still sucks because I just tried hfjhfhefhwehrfeldh.php with my site and it redirected to my custom 404 error page


----------



## Eriksrocks (Aug 7, 2005)

Well at least you can still make it work:


The Infinity said:


> Hey Erik,
> 
> Well I got it to work, but how it happened is very weird. I kept changing the htaccess over ad over, and I kept getting a 500 error, so I just moved all my custom error pages:
> 
> ...


----------

