Actions

Difference between revisions of "Enabling Search Engine Friendly (SEF) URLs on Apache"

From Joomla! Documentation

(Rewrote page as a step-by-step tutorial)
m (Undo revision 59477 by Mvangeest (talk))
Line 2: Line 2:
 
This article addresses SEF URLs under the popular, open-source Apache webserver. SEF URL implementation is possible under Microsoft's IIS webserver as well, please see [[SEF URLs on IIS]].
 
This article addresses SEF URLs under the popular, open-source Apache webserver. SEF URL implementation is possible under Microsoft's IIS webserver as well, please see [[SEF URLs on IIS]].
  
{{JVer|1.6}} In Joomla! 1.6, basic SEF urls are enabled by default. {{JVer|1.5}} In prior versions you need to use the Global Configuration to enable them. The instructions below still apply if you want to use Apache's mod_rewrite.
+
{{JVer|1.6}} In Joomla! 1.6, basic SEF urls are enabled by default.
 +
 
 +
{{JVer|1.5}} In prior versions you need to use the Global Configuration to enable them. The instructions below still apply if you want to use Apache's mod_rewrite.
  
 
==Apache Instructions==
 
==Apache Instructions==
 +
# Rename htaccess.txt to .htaccess.
 +
#: Uncomment "RewriteBase <nowiki>/</nowiki>"
 +
#: If Joomla is installed in its own folder, the enter the Joomla folder name after the backslash. e.g. "RewriteBase <nowiki>/</nowiki>yourjoomlafolder"
 +
# Make sure that Mod_rewrite is working. Check that the line shown below in the file "apache/conf/httpd.conf" is uncommented. If necessary, uncomment the line and re-start the Apache web server.
 +
#: <code>LoadModule rewrite_module modules/mod_rewrite.so</code>
 +
# In Global configuration, set the three SEF options. The action of the three parameters is as follows:
 +
#* '''Search Engine Friendly URLs.''' Converts the URLs from the native Joomla! format to the SEF format.
 +
#* '''Use Apache mod_rewrite. ''' Uses the Apache "mod_rewrite" function to eliminate the "index.php" portion of the URL. If you don't want to use mod_rewrite, set this to "No" and don't rename the htaccess.txt. The SEF URLs feature will still work. The only difference is that you will see "index.php" in the URL, for example, <code><nowiki>http://www.yoursite.org/index.php/faq.html</nowiki></code>.
 +
#**''Even if you do not use Apache mod_rewrite you may still rename the htaccess.txt to .htaccess''
 +
#* '''Add suffix to URLs.''' Adds ".html" to the end of URLs.
 +
# Enable 'System - SEF' plugin'''
 +
#:This plugin adds SEF support to links in your Joomla articles. It operates directly on the HTML and does not require a special tag.
  
These are step-by-step instructions. Please follow them in the order they are presented here. If a step fails, '''do not''' continue until you have solved the problem.
+
If your site does not work correctly after enabling Search Engine Friendly URLs, please see [[Why does your site get messed up when you turn on SEF (Search Engine Friendly URLs)?]]
  
# Rename the file <code>htaccess.txt</code> in your Joomla!'s base folder to <code>.htaccess</code>.
+
If turning on the '''Use Apache mod_rewrite''' option creates errors, please see [[How to check if mod rewrite is enabled on your server]].
# Log on to your Back-end and open the Global Configuration.
+
# Enable the '''Search Engine Friendly URLs''' option and ''Save''. This option converts the URLs from the native Joomla! format to the SEF format.
+
#: Check if your site works correctly. Your URLs should now look like <code><nowiki>http://www.example.com/index.php/the-­news/1-­latest­-news/1­-welcome­-to­-joomla</nowiki></code>.
+
#: If your site does not work correctly, please see [[Why does your site get messed up when you turn on SEF (Search Engine Friendly URLs)?]]
+
# Enable the '''Use Apache mod_rewrite''' option and ''Save''. This option uses the Apache ''mod_rewrite'' function to eliminate the "index.php" portion of the URL.
+
#: Check if your site works correctly. Your URLs should now look like <code><nowiki>http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla</nowiki></code>.
+
#: If this option causes errors, please see [[How to check if mod rewrite is enabled on your server]]. If ''mod_rewrite'' is not enabled, leave this option off. It does not matter if you leave the <code>.htaccess</code> file renamed.
+
# ''If you think this necessary'', enable '''Add suffix to URLs''' and ''Save''. This option adds <code>.html</code> to the end of URLs. There are different opinions on whether this is necessary or even useful. Search engines do not seem to care if your URLs end in <code>.html</code> or not.
+
# Open the Plugin Manager and enable the '''System - SEF plugin'''. This plugin adds SEF support to links in your Joomla articles. It operates directly on the HTML and does not require a special tag.
+
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]
Line 25: Line 30:
 
[[Category:Version 1.5 FAQ]]
 
[[Category:Version 1.5 FAQ]]
 
[[Category:Version 1.6 FAQ]]
 
[[Category:Version 1.6 FAQ]]
 +
[[Category:Category Management]]

Revision as of 10:12, 9 June 2011

<translate> Search engine friendly (SEF), human-readable or clean URLs are URLs that make sense to both humans and search engines because they explain the path to the particular page they point to. Since version 1.5, Joomla! is capable of creating and parsing URLs in any format, including SEF URLs. This does not depend on URL rewriting executed by the web server, so it works even if Joomla! runs a server other than Apache with the mod_rewrite module. The SEF URLs follow a certain fixed pattern, but the user can define a short descriptive text (alias) for each segment of the URL.

Internally, the local part of a SEF URL (the part after the domain name) is called a route. Creating and processing SEF URLs is therefore referred to as routing, and the relevant code is called a router. </translate>

This article addresses SEF URLs under the popular, open-source Apache webserver. SEF URL implementation is possible under Microsoft's IIS webserver as well, please see SEF URLs on IIS.

Joomla 1.6 In Joomla! 1.6, basic SEF urls are enabled by default.

Joomla 1.5 In prior versions you need to use the Global Configuration to enable them. The instructions below still apply if you want to use Apache's mod_rewrite.

Apache Instructions

  1. Rename htaccess.txt to .htaccess.
    Uncomment "RewriteBase /"
    If Joomla is installed in its own folder, the enter the Joomla folder name after the backslash. e.g. "RewriteBase /yourjoomlafolder"
  2. Make sure that Mod_rewrite is working. Check that the line shown below in the file "apache/conf/httpd.conf" is uncommented. If necessary, uncomment the line and re-start the Apache web server.
    LoadModule rewrite_module modules/mod_rewrite.so
  3. In Global configuration, set the three SEF options. The action of the three parameters is as follows:
    • Search Engine Friendly URLs. Converts the URLs from the native Joomla! format to the SEF format.
    • Use Apache mod_rewrite. Uses the Apache "mod_rewrite" function to eliminate the "index.php" portion of the URL. If you don't want to use mod_rewrite, set this to "No" and don't rename the htaccess.txt. The SEF URLs feature will still work. The only difference is that you will see "index.php" in the URL, for example, http://www.yoursite.org/index.php/faq.html.
      • Even if you do not use Apache mod_rewrite you may still rename the htaccess.txt to .htaccess
    • Add suffix to URLs. Adds ".html" to the end of URLs.
  4. Enable 'System - SEF' plugin
    This plugin adds SEF support to links in your Joomla articles. It operates directly on the HTML and does not require a special tag.

If your site does not work correctly after enabling Search Engine Friendly URLs, please see Why does your site get messed up when you turn on SEF (Search Engine Friendly URLs)?

If turning on the Use Apache mod_rewrite option creates errors, please see How to check if mod rewrite is enabled on your server.