Last week Cal Evans announced the release of the Bing404 Plugin for WordPress, a plugin that takes advantage of the Bing Search Library for PHP released by the Interoperability @ Microsoft team. Cal did a great job with those articles and I’d recommend checking them out.
When using the Bing404 Plugin instead of users seeing the standard WordPress error when a page is not found, Bing is queried for results within your site and a list of possibly relevant links is shown instead.
Here, I’ll share with you our experience getting started using this Plugin.
How It Works
Usually, users will receive a 404 error and a search box when they request page on your site that doesn’t exist.
If you don’t see the WordPress error handling above, but instead see the default IIS 404 error below, don’t worry. We’ll take care of this in Step 4.
When you install the Bing 404 Plugin, Bing will be queried for pages within your site when someone gets a Page Not Found error.
Give it a try here: http://wordpress.visitmix.com/foo
4. Enable IIS Pass Through Error Handling (not covered by Marco)
5. Test It
The first thing you need to do is install the Plugin; it’s in the WordPress Plugin Gallery. The easiest way to do this is to go to Add New in the Plugins section of your WordPress admin and Search for Bing404 (all one word).
You should get one result, which you just need to Install.
Next, select Install Now.
This will download the Plugin to your wp-content/plugins folder. Now, just click on Activate Plugin.
Start by visiting http://www.bing.com/developers/createapp.aspx, which will prompt you for a LiveID.
Provide a few details about the application.
This will generate an AppID,which you need to copy for the next steps.
Once you’ve activated the Plugin,you should have a new option for Bing 404 under the Settings in your WordPress admin.
Enter your Bing API Key, Site Specific Search and Number of rows to return and click Save Changes.
This may be the most tricky/confusing issue. Even after you’ve installed and configured the Plugin, you may still see the default IIS 404 error message.
This is probably happening because IIS, by default, is configured to not show detailed error messages for security reasons. The best workaround is to enable PassThrough error handling. This will allow your application to handle errors and still hide sensitive configuration details from the end user.
If you aren’t already using a web.config for URL Rewrite, etc. just create a new file named web.config in the root of your site. It should have the following contents:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpErrors existingResponse="PassThrough" /> </system.webServer> </configuration>
There’s a high likelihood that you already have a web.config for URL Rewrite. In this case, you just need to add <httpErrors existingResponse=”PassThrough” /> to the <system.webServer> section of the file.
Checkout this post on iis.net for more details.
Now all you need to do is enter a URL that doesn’t exist on your site. Instead of the traditional WordPress 404 error page, Bing will be queried for results within your site and provide applicable links.
If you’re interested in digging deeper, Cal has another article that talks about using the Bing Search Library with some sample code.