osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Re: Throwing Error 404 - msg#00231

List: web.midgard.user

Date: Prev Next Index Thread: Prev Next Index
On Mon, Jan 27, 2003 at 11:46:01PM -0500, Steven J. Sobol wrote:

> > The <(title)> is not called automatically but is filled with the title
> > string of current page, <(content)> is not called automatically but is
> > filled with the content of the currect page.
>
> Just so everyone is on the same page, What I'm trying to do is generate a
> 404 status (which will hopefully force APache to serve up my
> ErrorDocument) if specific conditions aren't met.

Can't be done without an internal redirect.

> I have some code that maps URLs of active pages to code snippets or
> articles depending on certain criteria. Instead of doing this in code-init
> where I'd have to make sure I put a code-init element on the root page of
> each site, I included this file from midgard-root.php, before the
> code-compat, code-global or code-init page elements are called.

That should work.

> It should
> work, but it isn't. (Well, the part that maps URLs to snippets or articles
> works perfectly, but it doesn't behave properly when all of the checks are
> completed and $JTN_notfound is still set to TRUE. Theoretically, it should
> work. This code is called immediately after midgard.so is loaded and the
> $midgard variable is populated, and before anything else happens in
> midgard-root.php. This code is executed for any website in a sitegroup
> other than SG0.
>
> <?
....
> //echo $JTN_notfound;
> if ($JTN_notfound)
> {
> header("Status: HTTP/1.0 404 Not Found");

This is incorrect. You want either
header("HTTP/1.0 404 Not Found");
or
header("Status: 404 Not Found");

I believe the first is the PHP4 preferred way.

And as noted earlier, it still won't (can't) serve up your apache 404.

Emile


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Throwing Error 404

On Mon, Jan 27, 2003 at 10:51:05PM -0500, Steven J. Sobol wrote: > > When I use 'wget -S http://stevesobol.com:8001/nf.php' it seems > > fixed now. I get an 404: > > But IE and Netscape don't detect that it is a 404. But do you still get the double status header? Because I don't. Try http://www.iris-advies.nl/this/does/not/exist/ > More importantly, Apache doesn't seem to realize it's a 404. I placed an > ErrorDocument directive in the virtualhost entry for this website. It's a > simple document that says "this is a 404". Pull up nf.php and that doesn't > happen. Apache is completely out of the loop at this point. The translate handler was given the chance to decide whether or not it could match the URL. Since that returned success, apache considers that particular matter closed. What remains is the possibility to send a specific status code to the client. > THAT'S the problem. I did have it originally in code-init and it did work > there. I moved the code to the ROOT style element because I am using the > code as a package which will be used for lots of clients' websites and I > didn't want to always have to remember to put the code-init code into the > root page. Doing things like this in the ROOT *can* work, but you cannot have any style stuff active. There must be no content sent before you set the status header, or PHP will sent the 200 for you automatically. Emile

Next Message by Date: click to view message preview

Re: Throwing Error 404

On Tue, 28 Jan 2003, Emiliano wrote: > On Mon, Jan 27, 2003 at 11:46:01PM -0500, Steven J. Sobol wrote: > Can't be done without an internal redirect. Alright... :> > This is incorrect. You want either > header("HTTP/1.0 404 Not Found"); > or > header("Status: 404 Not Found"); According to some debugging I did, the latter doesn't seem to work with PHP 4.3.0, you get HTTP/1.0 200 OK and down below that the Status header. The first method does work. > And as noted earlier, it still won't (can't) serve up your apache 404. Well, I thought about it. I think my original code from code-init had comments to just send the 404 and let the <(display)> element do the rest; that is a style element that I use that checks the information returned by the code I posted earlier, and pulls content from the appropriate place. I guess my big concern is search engines. If someone hits my page at http://some.url/active_page/nonexistent-content which doesn't map to anything and I send back a 404, they won't generate an entry for that page, right? I'm probably being overly concerned about this issue, but I plan on using this system (midgard+aegir+my customizations) for many clients down the road and I want to make sure it works properly. -- Steve Sobol, CTO JustThe.net LLC, Mentor On The Lake, OH http://JustTheNetLLC.com/ 888.480.4NET (4638) A practicing member of the Geek Orthodox religion!

Previous Message by Thread: click to view message preview

Re: Throwing Error 404

> Just so everyone is on the same page, What I'm trying to do is generate a > 404 status (which will hopefully force APache to serve up my > ErrorDocument) if specific conditions aren't met. And I'm beginning to think this is a bug in PHP 4.3.0. I've never had trouble sending custom Status headers before. -- Steve Sobol, CTO JustThe.net LLC, Mentor On The Lake, OH http://JustTheNetLLC.com/ 888.480.4NET (4638) A practicing member of the Geek Orthodox religion!

Next Message by Thread: click to view message preview

Re: Throwing Error 404

On Tue, 28 Jan 2003, Emiliano wrote: > On Mon, Jan 27, 2003 at 11:46:01PM -0500, Steven J. Sobol wrote: > Can't be done without an internal redirect. Alright... :> > This is incorrect. You want either > header("HTTP/1.0 404 Not Found"); > or > header("Status: 404 Not Found"); According to some debugging I did, the latter doesn't seem to work with PHP 4.3.0, you get HTTP/1.0 200 OK and down below that the Status header. The first method does work. > And as noted earlier, it still won't (can't) serve up your apache 404. Well, I thought about it. I think my original code from code-init had comments to just send the 404 and let the <(display)> element do the rest; that is a style element that I use that checks the information returned by the code I posted earlier, and pulls content from the appropriate place. I guess my big concern is search engines. If someone hits my page at http://some.url/active_page/nonexistent-content which doesn't map to anything and I send back a 404, they won't generate an entry for that page, right? I'm probably being overly concerned about this issue, but I plan on using this system (midgard+aegir+my customizations) for many clients down the road and I want to make sure it works properly. -- Steve Sobol, CTO JustThe.net LLC, Mentor On The Lake, OH http://JustTheNetLLC.com/ 888.480.4NET (4638) A practicing member of the Geek Orthodox religion!
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by