How to create SEO-friendly URLs in Joomla

Joomla provides a very simple way to create SEO-friendly URLs, or SEF URLs as they are also known.

SEO-friendly URLs are the URLs which can be read by a human and make sense about what content they hold. They follow a certain structure which provides the user to easily understand where, in the website’s structure, he is and how is this specific page categorized.

The general rule of thumb is that if the URL contains human-readable information then any Search Engine will be able to use this information just as well and index it accordingly.

SEO-friendly URLs in Joomla give a considerable boost in its Search Engine rankings and we strongly encourage everyone to enable them. Let’s see how!

How to Enable SEO-friendly URLs in Joomla

First you need to navigate to Joomla’s Global Configuration like in the screenshot below

go-to-joomla-global-configuration.png

Then, while you are in the Site Tab, at the right of your screen there is a section called SEO Settings. In this section, the first option called Search Engine Friendly URLs should be turned to Yes. This way more options will appear right under it.

From all the options that appeared, in this tutorial we are mostly interested in the first option called Use URL Rewriting. So, make sure that turn this option to Yes as well. Now everything should look like it is in the screenshot below.

joomla-configuration-seo-friendly.png

With those two options turned to Yes, in most server configurations you should be good to go just by saving the Global Configuration. However, there are certain exceptions regarding some servers which require a bit more work for the SEO-friendly URLs to work.

Those exceptions are separated into whichever HTTP Service type is used. For example, Windows Server use the IIS for all its HTTP needs. Linux servers on the other hand use a service called Apache or a newer one called Nginx.

Let’s see what you should do for each distinct Service if by chance you need to do more than just changing Joomla’s Global Configuration.

How to Enable URL Rewriting for Apache in Joomla

Apache Servers use a text file called .htaccess which holds instructions on how to construct URLs among a plethora of other things too.

If you do not have this particular .htaccess file, you can go ahead and create one like you would any other text file. Then, for the SEO-friendly URLs to work you should add into it what is shown in the code segment below.

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

Also you should know that there is a chance that you might have an htaccess.txt file instead. In that case you can just rename it into .htaccess and just make sure that it contains the code shown above.

How to Enable URL Rewriting for IIS in Joomla

IIS uses the same philosophy with Apache in terms of using a text file which holds instructions about URL Rewriting.

This file is called web.config and its contents in Joomla should be those depicted in the code segment below.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <location path=".">
   <system.webServer>
       <directoryBrowse enabled="false" />
       <rewrite>
           <rules>
               <rule name="Joomla! Rule 1" stopProcessing="true">
                   <match url="^(.*)$" ignoreCase="false" />
                   <conditions logicalGrouping="MatchAny">
                       <add input="{QUERY_STRING}" pattern="base64_encode[^(]*\([^)]*\)" ignoreCase="false" />
                       <add input="{QUERY_STRING}" pattern="(>|%3C)([^s]*s)+cript.*(<|%3E)" />
                       <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                       <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                   </conditions>
                   <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
               </rule>
               <rule name="Joomla! Rule 2">
                   <match url="(.*)" ignoreCase="false" />
                   <conditions logicalGrouping="MatchAll">
                     <add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
                     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                   </conditions>
                   <action type="Rewrite" url="index.php" />
               </rule>
           </rules>
       </rewrite>
   </system.webServer>
   </location>
</configuration>

Bare in mind that if by chance there is file called web.config.txt in your Joomla file structure then you should go ahead and rename it into web.config.

How to Enable URL Rewriting for Nginx in Joomla

Finally, an upcoming linux http service is called Nginx and is getting used by an increasing amount of servers each day.

Nginx uses a different a philosophy from the previous two services in a way that it doesn’t have a configuration file for each website. Instead, it uses one configuration file for all the websites it serves.

For Joomla websites the following Nginx Configuration in the code segment below is generally what is needed for SEO-friendly URLs to work among other things.

server {
    ....
    location / {
        expires 1d;
        # Enable Joomla SEF URLs inside Nginx
        try_files $uri $uri/ /index.php?$args;
    }
    ....
}

We hope that you liked our tutorial about SEO-friendly URLs in Joomla! If you want to be notified about all our latest content you can go ahead and subscribe to our Newsletter and follow us on Twitter!

About the Author
Joomla Author Editorial Staff

Editorial Staff

Editorial Staff at JoomlaBeginner is a team of Joomla experts led by Tassos Marinos. Contact us if you want to join our team. Follow us on Twitter or Facebook.
Sign up to our Joomla Newsletter
Get awesome content delivered straight to your inbox twice a month

Comments