News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
How to Avoid 404s and Redirect Old URLs in PHP
August 03, 2010 @ 14:15:27

On the SitePoint PHP blog today there's a new post showing you how to create a 404 page that will redirect people back to the page they're looking for (that used to be there).

It's often necessary to reorganize your site and change the URL structure but, assuming you have similar content, users should rarely encounter a "page not found" error. Producing unnecessary 404 pages is one of my top 10 development mistakes. In this article, we'll create an automated PHP redirection system that converts old URLs to a new address. It's not production code, but it will illustrate the basics so that you can adapt it for your own website.

They walk you through the creation of a 404 error handling PHP page, configuring your server to use it and making the mapping of new URL to old URL. There's even a bit to include if there's not a mapping for a requested page - returning a 301 HTTP header.

0 comments voice your opinion now!
404 redirect map url tutorial


php|architect:
Bing Powered 404 for non-WordPress websites
June 17, 2010 @ 09:10:29

Following up on his Bing 404 plugin for WordPress article, Cal Evans has put together an example for those not using WordPress to accomplish the same thing.

I had several people tell me that while they liked the idea, they didn't want to install WordPress just so they can have intelligent 404 errors. Several other people pinged me and suggested a way that you could use the Bing Search API to handle 404's without WordPress. As a public service, I am going to try and bridge the gap between these two groups. Going on leads provided by friends, I have hammered out a solution that works with Apache and PHP.

The solution uses a custom 404 page (as set in Apache) that pulls in the "top ten" links from the current site as reported back by the Bing.com search engine. With the help of the API making a request and getting back an object to loop through is simple. This could easily be adapted to accept terms based on the content page that they were trying to find or some keywords based on your site's content.

0 comments voice your opinion now!
bing wordpress search 404 error apache tutorial


NETTUTS.com:
404/403 Website Error Pages With PHP Auto-Mailer
April 20, 2009 @ 07:57:14

NETTUTS.com has posted this new tutorial you can use to monitor when and what pages people are trying to get to on your site that aren't found:

Although many web developers rely on server logs to keep an eye out for hits on error pages, I'm going to take a different approach by using a PHP generated email. In addition, we will spice up the design a bit, add basic navigation and link to the website sitemap.

He briefly explains what error (404/403) pages are and how they work before getting into the mailing portion - a script that, using the phpMailer tool, notifies you when people hit the 404/403 page and includes things like their IP, where they came from and what the requested page was.

0 comments voice your opinion now!
email automailer page message error website 403 404


Mark Kimsal's Blog:
Is Your MVC MIA When it Comes to 404s?
July 08, 2008 @ 07:51:20

In a new post to his blog, Michael Kimsal points out a post from his brother (Mark) that wonders if your framework handles 404 errors the best/most useful way it can.

This post is about the consistency of frameworks. Consistency is key to a low learning curve. [...] Yesterday, my brother asked me how he could capture 404 errors in Cognifty, as he was building an app that relied on dealing with random URL patterns. [...] After talking for a bit, we decided that handing off the request to a standard service (or controller) was the best way to handle this type of "error". He started searching to see if other frameworks had a consistent, or at least documented, way of dealing with missing controllers.

In his research he found one framework - the Zend Framework - that handed them by default as an error and passed them off to that handler. Mark notes that, depending on your frame of reference, this may or may not be considered a true error.

His Cognifty framework handles things a bit differently. It allows you to change the presentation handler to redirect to another url if an error like a 404 is thrown - a technically "more correct" way of handling things.

0 comments voice your opinion now!
mia 404 error framework zendframework cognify handle redirect


Matthew Turland's Blog:
Interesting Bug in the HTTP Streams Wrapper
April 14, 2008 @ 08:49:04

Matthew Turland has come across an "interesting bug" in PHP's stream wrappers functionality - some strange 404 or 500 HTTP errors in one of his scripts.

I wrote a small script a while back that's gained a surprising amount of popularity thanks to a plug from the site that it posts to. [...] I learned that this [connection from the script] could be done with streams, I attempted to implement it in that fashion, but ran into strange issues where I would get 404 or 500-level HTTP errors rather than the response I was expected.

He eventually found the bug related to his problem (in the 5.2.x branch) but happily notes that it has been corrected and will be patched in the upcoming 5.3 (and 6) branches.

0 comments voice your opinion now!
bug streams wrapper issue 404 500 connection header contenttype


Richard Miller's Blog:
UPHPU meeting on custom 404 pages
February 22, 2006 @ 06:49:49

From Richard Miller's blog today, there's a new post with content from the Utah PHP Users Group meeting that's just passed (Feb. 2006) on the topic of custom 404 pages.

When you try to visit a web page that doesn't exist, the server usually returns a 404 error message - "Page Not Found". At the Utah PHP Users group meeting last Thursday, Mac Newbold presented on custom 404 pages. Custom 404 pages can help maintain your website branding, help you fix broken links, and help your users find something useful when they don't find what they're looking for.

Custom 404 pages are even more powerful when you combine them with PHP. I certainly didn't expect the flood of ideas that Mac presented for using custom 404 pages.

Among the suggestions of things to do with the error pages are things like: sending an email when someone gets a 404, search the site for something similar, use it as a redirect for old to new URLs, and more.

1 comment voice your opinion now!
user group utah meeting february 2006 custom 404 pages user group utah meeting february 2006 custom 404 pages


U
February 16, 2006 @ 06:37:15

For the February 2006 meeting, they Utah PHP Users Group will be talking about Apache 404 handler scripts created in PHP.

Mac Newbold will present on PHP 404 handler scripts. Running PHP with Apache has some definite advantages. One that I use frequently is using a PHP script as the 404 document that apache uses when a page can't be found. You can use it for many things. PHP.net uses it to run a site search, to try and find the page you were looking for. You can use it to create "virtual" URLs, where one script handles requests for many different URLs and hands back dynamic content based on the page name. You can even combine it with things like GD to make dynamic images that are created on the fly for each URL.

The meeting is happening on the 16th at 7pm MST at the Linux Networx offices. You can RSVP and get a map to the location from their site...

0 comments voice your opinion now!
utah users group apache 404 script 16th 7pm utah users group apache 404 script 16th 7pm



Community Events





Don't see your event here?
Let us know!


version conference library language release podcast series framework security composer tool artisanfiles opinion laravel interview voicesoftheelephpant symfony list introduction community

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework