Custom errordocs not working in IE10

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

Ok.
Firstly, how do I "generate the 404 status code" ?
Secondly, I want to redirect them within the not_found.html to my internal /oops page. So do I then add the refresh after the Header part?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

I have this at the top of my index.php page

Code: Select all

<?php session_start(); 
header("Status: 404 Not Found");
include_once("/error_docs/not_found.html");
die();
And without when I run it locally, it takes me to the error page - no matter what page I try to execute.
If I run it LIVE on the server, I still get the blank white page.

ALSO - I don't know what you mean about parsing php in .html.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Custom errordocs not working in IE10

Post by Eric! »

LOL. I don't know what to say other than just to keep programming it for you.

Put this

Code: Select all

header("Status: 404 Not Found");
include_once("/error_docs/not_found.html");
die();
where your condition is for the meta refresh tag is. This is what you want PHP to do only when you need the error page to show up.

If it is blank on your live server then the error page probably doesn't exist where you think it does. Probably you're running this from a different directory and you need to fix the path.

If that is the option you choose then you're done. Don't worry about putting PHP into your not_found.html document. But just so you know some servers are setup to parse .html files with PHP in line, some are not. If you put some php code in to a .html file and it doesn't work, then you know apache isn't parsing them. Most of them don't by default. You can either rename not_found.html to not_found.php or change your .htaccess settings. See this.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

If I put that code in the top of my PHP page, no matter what page I visit, it directs to the not_found.html and redirects me.
So it is picking it up, but ALWAYS.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

Hold on - sorry. You are saying to put that in the not_found.html file ???
But still, what is telling the browser to go to there in the first place? The issues isn't with what is in that file, the issue is taking them there in the first place.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Custom errordocs not working in IE10

Post by requinix »

That code Eric posted goes wherever you made the decision to 404. Not in the header, which presumably executes for all requests, and as you surmised not in the 404 page itself either.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

sorry i'm lost.
I know some code goes in the not_found.html page, but IE10 is preventing me from getting there.

Even if I sound dumb here - what do I put where??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Custom errordocs not working in IE10

Post by Christopher »

You originally said:
simonmlewis wrote:I have created some custom error pages, that use the HTML META refresh, to take them to an internal PHP page.
It is a little confusing because you say you created some "custom error pages" and that they use meta refresh to go to an "internal PHP page". I don't know what "custom error pages" or an "internal PHP page" is? And, it is not clear why you are doing this, but the question is: where do you determine that you have an error that needs an "error page"? Is this being done in Apache? Or are these PHP pages that have some error condition?
(#10850)
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Custom errordocs not working in IE10

Post by Eric! »

@christopher to save you the trouble that I've already went through, he is talking about a php page that fetches other pages based on a query string. When a non-existing page is requested he wants to redirect them to an error page ("custom error page" or "internal php page"). He posted some example code, but couldn't figure out how to redirect it for IE10 using a meta refresh tag because IE10 doesn't refresh and instead generates it's own 404 html. He is redirecting to his "custom page" by echoing only a meta refresh tag (no other HTML, nothing). Anyway I tried to explain the use of Header and 404 code and gave an example. I was hoping he would figure it out on his own. He stuck my example 404/include lines at the top of the page so naturally it presented his 404 error page for everything, not just the error. I figured with some time he'd figure out he needs to put the header and include and die in the section of code where he detects only the missing page and not for every condition. I told him this in my last post, but I didn't want to repeat myself again.

Simon doesn't seem to understand to replace the echo meta refresh tag crap in the error condition of his code with the 3 lines:

Code: Select all

header("Status: 404 Not Found");
include_once("/error_docs/not_found.html");
die();
Perhaps you can explain it from here if he is still confused.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

I don't think the issue is that I cannot redirect it - the issue is IE10 doesn't take the user to the not_found.html file.

I know full well out to redirect using various methods - but IE10 has a "friendly" means of going to its own page!

I'm sure if I put that header code into not_found.html it will be fine. But how do I get IE10 to take the user there in the first place.
THAT IS THE ISSUE. HOW DO i TELL IE10 *WHERE TO GO* INSTEAD OF ITS OWN PAGE?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Custom errordocs not working in IE10

Post by requinix »

Do. Not. Redirect. At. All.

Like I said a long time ago, IE will show it's own error page if you don't show a large enough error page yourself. I believe 512 bytes in the content is the threshold.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

Oh is it really that simple? Mine is 224bytes.
So if I actually pack it out with something, it would work??
Reading about IE10, that User Friendly page is set as default. So if the bytes are 512+, it won't show theirs?

Apart from just filling it out with lots of P and <br/> tags, how do I go about making it work?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Custom errordocs not working in IE10

Post by simonmlewis »

Well I'll be bloomin damned - it does!!!
I just added a load of &nbsp; and a few paragraphs, and it works in IE. Does IE10 see lower byte files as less friendly then?

Will look at the guys header scripts next, in place of my meta refreshes if they are better?!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Custom errordocs not working in IE10

Post by requinix »

Basically, yeah. 512 bytes is really small, and if an error page isn't that large then there's probably not that much content to show. For the typical user, IE's error pages are nicer than (for example) Apache's default 404s and 500s.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Custom errordocs not working in IE10

Post by Eric! »

Will bots follow a meta tag? I still think the status header should be set. So if you are using the meta tag then the error page should have

Code: Select all

header("Status: 404 Not Found");
at the top too.
simonmlewis wrote:I don't think the issue is that I cannot redirect it - the issue is IE10 doesn't take the user to the not_found.html file.
Using a refresh tag is a type of redirection and it wasn't working on IE 10, apparently because it was too small. You can also do the status code + include which I think is cleaner and more standard. Also if someone (like a search bot) is not using a webkit tool they would probably not follow the refresh url.
Post Reply