Welcome Guest, Not a member yet? Register   Sign In
Controller Based 404
#21

[eluser]theQco[/eluser]
Yes. That would be great if I could accomplish that.
#22

[eluser]sophistry[/eluser]
ok, great.

to state the obvious... you can't send two location headers in one page. if you want 404s to be issued by your webserver, you have to issue them.

and, what did i discover by looking at the CI source? the show_404() does not actually show that CI issues a 404 header. bizarre. anyway, you should really send a 404 if you want a 404. EDIT: i just tested the show_404() function and it does indeed send a 404 header, but it's not in the source code, so how does it get there? EDIT2: sorry, the header() function that actually issues the 404 is in the errors/error_404.php file. i wonder why it's done like that and not in the show_404() function?

doing a 404 then immediate 301/2 is not recommended because it confuses search engines and spiders (i found this to be a good summary):
http://forums.searchenginewatch.com/arch...-1884.html

anyhow, if you are prepared to ignore that advice, are you allowed to use cookies? if so, continue using your overwritten show_404() function and store the URI that triggered the 404 in a cookie (or session or session db if you want to go that way).

you also have two choices in CI redirect(): header and meta refresh. you might want to do meta refresh to avoid sending a 404 and then a 302
#23

[eluser]zippy[/eluser]
I rest my case.

We're all doomed, Captain.
#24

[eluser]sophistry[/eluser]
@Q... i have a feeling we're being watched. do you smell something?
#25

[eluser]zippy[/eluser]
@sophistry

Nice handle, apropos.

OK. I'm 50-something. I've been in this game since the late '70s.

I remember MS/PC-DOS 3.0 with affection. I remember MASM 1.0, its infernal linker and the magical exe2bin.

I specifically remember a particular MASM directive:

ASSUME NOTHING

It's tatooed in my head, and it's served me well.

What is it that you bring to this party, exactly?
#26

[eluser]sophistry[/eluser]
oh zippy, i didn't see you standing there... ;-)

sorry, i was just reacting to your snarky commentary with no substance or "here's how i would do it" kind of input.

no need to have a pissing contest - clearly you would win on that score.

what would you suggest to our poor sailor here? other than, "jump off this cursed framework ship and go back to coding pure PHP."
#27

[eluser]Douglas Clifton[/eluser]
I've been working on this very issue all afternoon. With that said, this thread has been both insightful and hands-down the most entertaining I've come across in the forums to date. Thanks folks, on both marks.

I agree with zippy. CI is cool but some of the stuff under the hood is, well, puzzling to be polite. Clinging to php4 is a mistake if you ask me, but it seems CodeIgniter will not be dropping support for php4 anytime soon.
#28

[eluser]Alan Wizemann[/eluser]
Okay, maybe I am missing something here, but the solution to me is very simple and was touched on but not expanded. All you need to do is add your error handling in the 404 file itself (errors/error_404.php) in the application folder.

To get what you want, because you already have the entire instance, you can log your users action and then simply add this:

Code:
<?php
redirect('/your-default-controller-or-something');
?>

Then the user is sent to where you want them to be.

Please let me know if I am missing something for your use-case, but the error pages in the application folder were specifically designed for something like this (I think).
#29

[eluser]wiredesignz[/eluser]
[quote author="Alan Wizemann" date="1248070116"]...Please let me know if I am missing something...[/quote]

Consider that you cannot simply "redirect" (which returns HTTP header 301) from a page not found when you should actually return HTTP header 404.
#30

[eluser]Alan Wizemann[/eluser]
My use case was to simply override any not found and send them back to where I think they should go. I should probably but in the redirect that it is a permanent one.




Theme © iAndrew 2016 - Forum software by © MyBB