Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

SOLVED: Problem with 404 Error Page for .php file extensions


Reply


5 Posts   4810 Views

Avatar
LinseyM

Community Member, 99 Posts

4 November 2009 at 4:56am

Edited: 04/11/2009 5:28am

Hi all,

Wonder if you can help me?

Got an email from client this morning. The 404 Error page is giving some strange results.

There are still some links on google to their old site which do not display the SS 404 Error page as expected, eg:

http://www.globalconnects.com/translation-home.php

However, if you were to try something else, such as

http://www.globalconnects.com/translation-home

or

http://www.globalconnects.com/translation-home.html

that works fine!

But as soon as you add in the .php extension it goes back to what appears to be the server-side error pages.

I am sure there is a good reason for this, but I don't know what it is!

I've logged into the server control panel and tried setting "Custom Error Docs" to both on and off, but that made no difference.

Any help appreciated.

Thanks,

Linsey

Avatar
rbquirke

Community Member, 70 Posts

4 November 2009 at 5:12am

Hi Linsey

The reason for this is that Silverstripe uses php files itself, so it cannot handle urls ending in .php within it's own cms 404 page system.

What you can do is add a line to the end of your .htaccess file like this:
ErrorDocument 404 /page-not-found

This tells the server to redirect 404's that Silverstripe doesn't handle back to a specific page. The url I have set it to there is the default url for the "Page Not Found" page in SS. You should double check in the cms that your SS 404 page has the same url. If not, change accordingly.

Ronan

Avatar
LinseyM

Community Member, 99 Posts

4 November 2009 at 5:23am

Hey Ronan,

Thanks for the speedy reply... appreciated.

I kinda thought it was something along those lines, but I was stumped as to what to do about it!

So, just to clairfy... I should put the following line of code:

ErrorDocument 404 /page-not-found

exactly as it appreas above, into the .htaccess file in the site root?

Cheers!

Linsey

Avatar
LinseyM

Community Member, 99 Posts

4 November 2009 at 5:23am

p.s. yes, that is what the 404 page is called.

Avatar
LinseyM

Community Member, 99 Posts

4 November 2009 at 5:27am

works like a charm, thanks.