In this video, we'll explore a few reasons a visitor might reach a "404 Page Not Found" error page, and take a look at how the "Fix 404 Pages" feature of the Redirect module can fix these problems.
Fix 404 Pages
Now, let's take a look at the "Fix 404 Pages" tab. A "404 Page Not Found" error occurs when a visitor tries to access a page that does not exist on your site. Some common reasons for this include:
- If you are rebuilding an existing site in Drupal, it is likely that you will not recreate the URL structure exactly as it was before. If visitors had a URL saved, or another site was linking to yours and you do not recreate that URL, visitors will receive a "404 Page Not Found" error when they try to access that URL.
- Another site may link to yours, and misspell a URL.
- A user might misspell a URL when typing it in manually. (This can frequently happen when a URL contains words that are commonly misspelled.)
- If you change a URL alias, and do not create a redirect from the old alias. (Checking the "Automatically create redirects when URL aliases are changed" box in the settings will take care of this automatically.)
As an example, I'll try to access a few pages that do not exist. (about-us and users/1/edit)
You can see what pages on your site are returning a "404 Page Not Found" error by visiting "Reports => Recent log messages" (admin/reports/dblog), and filtering by type "page not found". You could then create URL redirects manually for each of these pages, but the Redirect module makes this much easier.
- Go to "Configuration => Search and metadata => URL redirects => Fix 404 pages" (admin/config/search/redirect/404)
Here, you can see that there are a few paths that I have tried to access that do not exist. Next to each one there is an "Add redirect" operation.
- Click "Add redirect"
When we click "Add redirect" we are taken to a form where we can specify where we would like users to be redirected when they reach the page that does not exist.
- From: This is the path users are trying to access
- To: This is the page users should be redirected to
- Advanced Options
- Redirect status: You can explicitly set the redirect status for each redirect. If you do nothing, the default status will be used.
I'll create a redirect from "about-us" to "about"
Then if I enter "about-us" in the address bar, you'll see that we are redirected to the "about" page.
I'll go back and create a redirect from "users/1/edit" to "user/1/edit"