If someone visits a page that does not exist, then a server will return a 404 not found error. Broken links may have very bad impact on your website’s reputation, frustrate your visitors and result in smaller number of visits. That is why it is so important to avoid 404 error pages as much as possible.
Of course not all 404 errors messages on Joomla site are bad. If you have deleted an article or product because it was no longer relevant on your website, then 404 error for such content is fine. Google will simply remove that page from the search results after some time.
The things are different when 404 page not found error occurs for a content that is still present on your website but under a different URL address. This may happen, for example, when you update the article alias or category.
How to find 404 pages and broken links on a website?
There are many ways to determine the broken links on your website. Let’s take a look on how to find them using Google Search Console and Joomla’s Redirects Component.
Google Search Console
Google Search Console is a free web service that helps you monitor and maintain your website’s presence in Google Search results. It is a must have tool for each owner of a website.
To find all issues that Google bots encountered during crawling of your website, you need to navigate to “Crawl -> Crawl Errors”:
Under the graph you will find a list of pages with errors. If you click on any of the items, you will get more information about the error page and where it was linked from:
Joomla Redirects Component
Also Joomla gives us a possibility to manage 404 pages. Redirects component was introduced in Joomla 1.6 and it can be very useful, especially for small websites.
To see a list of of 404 pages go to “Components -> Redirects”:
NOTE:Make sure you have enabled the “System – Redirect” plugin in “Extensions -> Plugins”, otherwise the Redirects component will not collect any URL.
How to fix 404 pages and broken links on a website?
Once you have a list of broken links on your website you can proceed to fix them. The broken links you can repair by redirecting them to working pages.
Repair broken links using Joomla Redirects component
Let’s get back to the Joomla’s Redirects component. Beside the fact, the tool is collecting the broken links, it also allows to repair them. If you click on any broken URL from the list you will see this page:
- The broken URL address
- The new URL address. The broken URL will be redirected to this one.
- Make sure the status is “Enabled”
- Click on “Save & Close”
301 redirect for broken links in .htaccess
Another way to repair a broken link is to make a 301 redirect in the .htaccess file.
To redirect a single URL you can add the following rule:
RewriteRule ^old-page$ /new-page [R=301,L]
This rule will simply redirect the old page:
To the new page:
To redirect all pages from old category to another, you can use the following rule:
RewriteRule ^old-category/(.*)$ /new-category/$1 [R=301,L]
This rule will redirect all pages from old category, like:
To the new category:
NOTE:Make sure you have the “URL Rewriting” option enabled in “System -> Global Configuration”. Along with this option you need to rename the htaccess.txt file to .htaccess otherwise the redirect rule will not work.
Mark broken links as fixed in Google Search Console
Once you repair broken links, you can mark them as fixed in Google Search Console. This way you will remove these pages from the list.
If the broken link was not fixed, it will appear back on the list once Google crawl it.