Using the .htaccess file for redirects is not a great idea when it comes to performance. Do remember that your web server needs to locate, load, and parse the .htaccess
file(s) on every request. This means not just the request to load the page, but also all HTTP(S) requests to load the individual CSS, JavaSript, image, video etc files. A .htaccess file with a hundred or so redirects would add between a dozen and a hundred milliseconds of page load time on average.
Instead, we make use of an implementation detail of Joomla!.
The default .htaccess
content of Joomla (shipped as htaccess.txt
) has the following stanza towards the end:
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
This tells the web server to load Joomla's index.php
whenever it is asked to access something which is neither a file nor a directory on the server's filesystem.
When Joomla's index.php
file is accessed, Joomla “boots up” its application, which is to say that it loads its absolutely necessary core files, system plugins, tries to figure out if it can handle the URL requested, and then asks the plugins to handle the onAfterIntialise
plugin event. The System – Admin Tools plugin handles this event, and that's where we do our redirection magic.
We check the requested URL against the list of redirections stored in the database. If something matches, we ask Joomla to issue an HTTP 301 redirect to the configured target (“Redirect to”) URL. Joomla dutifully does so, and stops processing anything further.
For the purposes of SEO these are identical to redirections taking place at the web server level with .htaccess
code. However, since the redirection code only runs once per page load, instead of on every request, it has a much smaller effect on the performance of your site. Since your site loads faster, it only does good things to the site's search engine score.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!