301-redirects (Joomla core vs .htaccess)

Setting up correct redirects is often the core business of any SEO consultant. It is the solution for many failed site set-ups and smaller issues. As explained in the next article, you should avoid 404 errors (page not found) as much as possible. Of course, we can not prevent all of those. If a user mistypes a URL that can hardly be foreseen (unless you are aware of known typo's people make), but in a lot of other cases they can be avoided easily. Especially if you are migrating from an old site to a new one, your URL's will change. When users do not update their bookmarks they end up on the old, non-existing URLs. Also, the Google index will take a while to update, and it will keep on sending users from the search results to your old URL's. This can heavily impact your search rankings! The same counts for smaller changes. If you change an alias for an article or a menu-item, the URL will also change.

The way to go is to determine what your old URL's are, and to re-route them to the new ones. Technically, this should be done through a so-called 301-redirect. Such a redirect is accompanied by a permanent-moved-code (301). This lets Google and other search engines know that the old link should not be used anymore, and also informs them of the new URL.  You should make sure that the new URL matches the old one as close as possible. In the example of site redesign, where all URLs are changed, you can set up redirects in 2 ways:

  • If you are lazy, you could choose to let all links automatically end up on the homepage. Then you have at least informed Google that they have been redirected, but you may lose all rankings built up for the specific pages.
  • Better is to reroute the links on a page by page basis. This is a lot more work, but will give much better results.

Then you also have to consider when to apply redirects. In the case of planned situations (like a redesign), both the old and the new URL structure are known. Then the best way to go would be to determine and fix these URLs before actually upgrading or changing your site, but as long as you quickly fix them after the URLs changed, you should be fine: in this case you simply monitor your 404-pages and fix them one by one.

Redirect Manager Component in Joomla

Joomla ships with a mechanism to monitor 404-errors that also allows you to set a redirection target. Go to Components -> Redirect and you will see them in the Redirect Manager: The first time you use it you will be notified that you first have to enable the Redirect plugin from the Plugin Manager. Of course first of all it should be enabled, but you also have the option to switch on the Collect URL's option. The reason it is switched off by default is that the database could be flooded with redirect URL's if you don't monitor them. Every site has them, also correctly set-up sites. This is mostly because of bots and hackers crawling your site for exploits. That is why I advise you to either monitor regularly (on a monthly basis) or to only monitor URLs at times when you know you can expect 404-issues (say, after a site redesign). I usually choose the latter option.

In the Redirect Manager, you will now see a list of URLs that generated 404-errors:


Click on any of the items listed:

redirect component in Joomla

Opening any specific item will allow you to enter the new URL (either relative or absolute) and enable the record.

Redirects in bulk

The method as described so far allows you to set redirects on a one-by-one basis. However, there is is also an option to route multiple records to one destination-URL in bulk. To do so, select the records you want to change, and set a new destination in the field located under the list:

redirect in bulk

This can save you a lot of time. Note that the records are enabled immediately, no need to set this separately.

Redirect Component: stop logging new URL's

There used to be one little disadvantage to the Redirect Component: As long as the plugin is enabled, it keeps logging all 404-errors Some sites suffer funny 404-errors (often generated by hackers and bots) continuously, which can seriously fill up the logs, so keep an eye on this. This can even fill up your database up to the limits! You can, of course, clean up the incorrect records manually, but that can be quite a task. The only alternative used to be to switch of the plugin, but that also made the existing redirects inactive. However, since Joomla 3.4, there is a new setting in the System - Redirect plugin (access it from the Plugin Manager). This is the Collect URLs setting:

collect urls redirect manager

As long it is on, it keeps collecting URL's, but if it is switched off, it will stop doing so, but the earlier configured redirects remain active. This is really the one feature that the component was lacking, and now it is an extremely useful component that I will actually use!

By the way, another function that is a bit hidden is the Activate advanced mode button in the general options of the Redirect Manager component. It does not immediately tell you what it does, but it gives you the option to specify the HTTP-response code in your individual redirects. The default is a 301-redirect, but now you have the option to change this to anything you want. I do not see the direct need to do so, but at least you have the option to do so now:

redirect status code

An alternative for the Redirect Manager component is to create them manually in .htaccess:

Custom redirects in .htaccess

Often, it might be just as easy to perform your 301-redirects in an .htaccess file. Especially for technically more skilled persons this is an often used method. Also these redirects have a slight performance gain, as they are executed before Joomla is activated. To use them, define your source and destination URLs, and enter the following example code:

RewriteRule ^oldpage1$ "http://newsite.com/newpage1" [R=301,L]
RewriteRule ^oldpage2$ "http://newsite.com/newpage2" [R=301,L]

The good thing is that this is a very exact way of dealing with your redirects. No extension needed, as long as you know what you are doing. Also, performance is least affected, as these redirects are executed by the Apache server software before Joomla is even activated.

You can also bulk redirect URL's using patterns. As an example, the following code can be useful when you change the setting for adding a .html suffix (in Global Configuration) from Yes to No.  Then the following block of code will redirect all URLs with a suffix to the corresponding URL without:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

(Note that the first line is usually there by default, so place the other 3 lines after this one).

Check out this URL for a whole bunch of advanced examples: www.gist.github.com/ScottPhillips/1721489 

Finally: don't forget your images! They need redirecting just as "normal" pages. See this blogpost here: www.gsqi.com/marketing-blog/how-to-redirect-images-during-website-redesign-or-migration.

Possible SEO disadvantages of 301-redirects

Note that when you redirect a URL, the "value" of the old URL is mostly transferred to the new one, but not 100%. In this study by Moz, it was found that 10-15% of the average rankings were lost when URL's were redirected. Especially when redirecting is not a must, say when you just want a slightly cleaner URL than the existing one, (maybe /swimming-pool versus /swimmingpool-constructor), this might be a consideration.

Redirect extensions

Of course, there are nice extensions for this purpose as well. A nice one is Yireo's Dynamic 404, which is capable of 301-redirecting not-found pages to the most corresponding existing one. By the way, since version 4.5, also SH404SEF has the option to automatically forward 404-errors to the most corresponding correct page.

Run a Full Website Scan in Minutes

Joomlaseo.com is fully built and written by Simon Kloostra, Joomla SEO Specialist and Webdesigner from the Netherlands. I have also published the Joomla 3 SEO & Performance SEO book. Next to that I also sometimes blog for companies like OStraining, TemplateMonster, SEMrush and others. On the monthly Joomla Community Magazine I have also published a few articles.

Joomlaseo.com is not affiliated with or endorsed by The Joomla! Project™. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.
© 2021 Joomlaseo.com. All rights reserved.