A redirect is simply a URL or web address that's set to point somewhere else. For example, if I wanted, I could make kevinsguides.com/about-us redirect to kevinsguides.com/about.
Joomla includes a relatively simple, but useful URL redirection feature. Knowing how to use this is essential if you plan on changing the navigation structure of your website. Otherwise, potential users may be taken to the wrong page and encounter errors. Redirects that are not handled properly may also result in your pages being dropped or lowered in search engine results.
When to Redirect
There are a few key reasons you might want to create a redirect.
- You're fixing a mistake with your menu
- You're reorganizing your content
- You're changing the name of an article or page, and its alias
- You want to catch common mistakes or fix problems that occur when users manually type web addresses (e.g. automatically make site.com/info redirect to site.com/about if you have an about page but not an info page)
As a rule for any public facing website, ALWAYS create new redirect rules whenever you change the URL of any page. Especially if you're using URL Rewriting.
I recently updated where Joomla 4 articles are stored on this website. Previously, they were all under https://kevinsguides.com/guides/webdev/joomla4. I decided to get rid of the "joomla4" alias and make it just "joomla." This way, as I update my articles for the latest version of Joomla, they no longer say "joomla4" in the address bar.
Before I made this change, many of my articles on Joomla received significant traffic from Google and other search engines. All those results were pointing towards the old "joomla4" links and now they need to point to the new "joomla" links. Visiting the old links results in a 404 file not found error, since the old links are broken. I resolved this with Joomla's built in redirect system.
Before you begin, ensure the redirect plugin is enabled. The easiest way to tell is to visit the redirect manager, where we'll be creating all our redirects.
You can find this under the System Dashboard in the backend of your site.
If you see a red warning message, you need to enable the plugin. If you see a success message, or links already are showing, you're probably good to go.
Leave the settings alone and enable the plugin if it isn't already.
Now let's return to the redirect manager. The option to collect urls should be enabled.
The URL Collection option automatically records every known event where a URL was not directed properly. It doesn't do anything with them, but rather tells you there's a problem.
For example, if I have a "Shop" page at mysite.com/shop, and people keep accidentally typing "mysite.com/store" - I would see that here.
In this example, it's recorded that "store" is not a valid URL. It says it's expired, but this could also mean it never existed, or the user had a typo.
Some important metrics are shown here:
- Created date
- When someone first tried to access this invalid URL
- 404 hits
- How many attempts or views this invalid page has
- Status code
- Relates mainly to SEO. We'll discuss soon.
- Referring page
- Where they're coming from (if it could be determined)
- This could be another page on your own site, a search engine, etc.
- For example, if the link from Google is expired, it will say "google" here
Remember, in this scenario I never had a "store" page to begin with. People are just accidentally typing the wrong thing. I can use a redirect to send people to the page they were likely looking for. So even if you never change your links, it's still helpful to see if users are accidentally trying to go to the wrong page. If you only have one 404 hit, it might not warrant correction. If it happens a lot, you probably need to provide an appropriate redirect.
Clicking the expired url opens the redirect editor. This item's been pre-populated with the details of the broken URL.
I left the old broken url alone and updated the new url to point to /shop. Then I set the redirect to enabled and saved it.
The Status Code is something search engines are supposed to look at to help index your site or build a sitemap. A status of 301 means this is a permanent redirect. This is the most common type of redirect, and the one you'll likely use.
Now, whenever I go to "j5test.test/store" it takes me to "j5test.test/shop" instead!
The same could be done if I changed the menu structure of my site. Suppose I want to rename my article category alias "documentation" to just "docs" for simplicity. Now, all the links under /documentation are broken.
If you only have a few links, you might be fine manually adding each correction one at a time.
However, if I have a dozen pages under my /documentation URL. It could become time consuming, adding them all one at a time.
We can use the bulk import tool (in the toolbar - NOT the batch update tool at the bottom) to add many redirects at once. Just type the old url on the left, the vertical bar (pipe) | key, and the new one on the right. Of course, you still need to know all the old and new links. If they follow the same format, it should be relatively easy.
You could also use something like find/replace with your text editor to bulk edit them.
Make sure all your new redirects are enabled when you're done. And test to make sure it works.
That covers the basics of Joomla's redirect system. Again, I would encourage you to periodically check it to see if users are commonly being taken to broken pages.
If your site experiences a ton of traffic, you might actually need to turn off the collect urls option in the plugin settings, and use some other analytical tool to track broken links. Since it generates a new record every time a broken link is used, this can balloon to thousands of entries rather quickly. Periodically use the "purge disabled" option to remove broken entries you don't want to deal with.
If you need more advanced control over redirection, several extensions may be helpful.
This AdvancedRedirect extension allows you to create custom redirects using expressions. This way, you can update dozens or hundreds of similar links at once.
The paid JRedirects extension has support for automatically generating redirects., which may be useful for larger sites.