nonSEF url (query) redirection in Joomla to SEF urls

After upgrading an old Joomla website (J1.5 or J2.5) to Joomla 4 we had to redirect the old, non-SEF URLs to new SEF ones. In this case SEO was not a big factor but we wanted to use SEF urls anyway. Most of the Joomla non-SEF urls (queries) are the same in Joomla 1.5 and in the latest version Joomla 4.x. In most case Joomla will "answer" the query.

Joomla non-SEF url (which is basically a query):

If your new Joomla site will serve SEF urls the old urls may come back from Search engines like Google or Bing. It could duplicate your content since bot urls will be indexed.

To avoid this we need to redirect the old url / query to the SEF one.

If the url you want to redirect is not a nonSEF url you should use core Joomla features not htaccess

301 redirection with .htaccess

Sometimes Joomla redirect plugin or other redirect plugins like REDJ component & plugin don't work if a query needs to be redirected. This time we used .htaccess 301 redirection for that purpose. In the following there are two urls to be redirected via 301.

Your old urls:

Will be redirected to here:

With this code inserted in .htacess file:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=15 [NC]
RewriteRule ^index.php /new-alias.html? [R=301,L,NE]

RewriteCond %{QUERY_STRING} ^Itemid=565 [NC]
RewriteRule ^index.php /sports/climbing.html? [R=301,L,NE]

You can check your .htaccess rules here.

Code in .htaccess file
Redirecting non-SEF URLs to new, SEF URLs in .htaccess file, CPanel

SEF url redirection to SEF url

We highly recommend to use .htaccess redirection if there is no more option left to you.

For redirection from

to here

You should use core Joomla redirect plugin or REDJ component or other php based solutions. It will be much more easy to manage redirects with these tools and there will be less performnce loss since the rule won't be checked on every pageload. With these Joomla tools you can avoid redirect loops as well.

How to find .htacess file in your Joomla root in Cpanel?

01 Go to your CPanel ➙ File Manager ➙ public_html.

02 On the top right corner click on Settings, and tick "Show Hidden Files (dotfiles)" checkbox, and Save.

03 Look for the .htaccess file in your public_html (in most case).

If your Joomla redirections are messed up or your have some problems with your Joomla SEO you are in the right place we provide Joomla support.

Contact us!


Cloudhoreca Kft. and this site is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.