How to Remove www from Your Joomla Website URLs

For one reason or the other, you might decide to remove the www part from the URLs of your Joomla website. It might be that you have a short domain and you may want to emphasize the shortness of the domain even more, or it might be that you just don’t like seeing www in your URLs. Some people mistakenly think that removing (or having) www will favorably affect their SEO standings – this is a myth. However, having consistent and non-redundant URLs by removing (or adding) www from all your URLs will certainly help your SEO. This is because of 2 things:

  • A consistent website will look more professional from a search engine perspective.
  • There will be no non-intended duplicate content on your website (for example, http://www.yourjoomlawebsite/article-1 and are considered to be duplicate content – although this duplicate content is soft, and is usually not punished by search engines).

Now, how to remove www from your Joomla website URLs?

There are two ways to do this: one by modifying your .htaccess file and another by modifying your index.php file. We recommend modifying your .htaccess file because it’s easier and more efficient and because you won’t have to fiddle Joomla’s core code. Only go for the latter option (index.php) if you don’t have access to your .htaccess file.

  • Removing www using .htaccess

    Simply add the following code to the beginning of your .htaccess file1:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^
    RewriteRule (.*)$1 [R=301,L]

    (Note: we have discussed redirecting non-www to www before in our article about handling duplicate content on your Joomla website.)

    Once you add the above lines, save the file, and upload it to your root directory. Try going to, you will notice that you are automatically redirected to

  • Removing www by modifying your index.php file

    As stated earlier, you should only modify your index.php if you’re unable, for some (mysterious) reason, to modify your .htaccess file, this is because you will be modifying a core Joomla file, which means that your edits might be wiped out (or affected) by future upgrades.

    In any case, to remove www from your Joomla website URLs, you should add the following code at the beginning of your index.php:

    function redirectURLNoWWW() {
    	$currentURL = "";
    	($_SERVER["HTTPS"] == "on")? $currentURL = 'https://' : $currentURL = 'http://';
    	$currentURLNoWWW = str_replace("http://www.", "http://", $currentURL);
    	$currentURLNoWWW = str_replace("https://www.", "https://", $currentURL);
    	if ($currentURLNoWWW != $currentURL)
    		header("Location:".$currentURLNoWWW, TRUE, 301);

Note that there are many 3rd party plugins that will also do the redirection for you, but we just wanted to show you how to do this manually! Doing this manually is sometimes better (especially when doing it through the .htaccess file), because some 3rd party plugins may create conflicts with your website.

If you need help doing the above, then you have found the right place! Just contact us and we’ll take it from there! It usually takes us very little time to do the above and our fees are very reasonable!

1Please note that most GoDaddy servers (at the time of writing this post) do not load the new .htaccess file instantly – and sometimes it might take up to an hour for your .htaccess to take effect.

2 Responses to “How to Remove www from Your Joomla Website URLs”
  1. Comment by James — November 9, 2022 @ 9:38 am

    Alas, the solution above only works if Joomla is installed in the root directory.

    If Joomla is installed in say, http://[]/joomla/, then the rewrite will break the site. Not sure how to incorporate a check on directory structure and then rewrite on whether Joomla is installed in the root public director or not, but a quick and dirty solution is to modify the .htaccess code to incorporate the installed directory. For example:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^
    RewriteRule (.*) http://[]/joomla/$1 [R=301,L]

    The rewrite must preserve the directory structure so the rendered url works! Also, the solution does not deal with http –> https but that’s another story!

  2. Comment by James — November 9, 2022 @ 9:46 am

    Here’s a bunch of other .htaccess code I have used on Joomla root directory installs i.e. joomla is installed in the public directory root.

    #Force http to https and www to non
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    # End Force

    # Removes index.php from URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
    # End Removes index.php

    # Removes index.html from URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.html [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.html/*(.*) /$1$2 [R=301,NE,L]
    # End Removes index.html

    # Removes index.htm from URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.htm [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.htm/*(.*) /$1$2 [R=301,NE,L]
    # End Removes index.htm

Leave a comment