Suchmaschinenfreundliche (SEF) URLs aktivieren

From Joomla! Documentation

This page is a translated version of the page Enabling Search Engine Friendly (SEF) URLs and the translation is 29% complete.
Other languages:
Deutsch • ‎English • ‎français • ‎português do Brasil • ‎中文(台灣)‎

Suchmaschinenfreundliche (SEF-search engine friendly), vom Menschen lesbar oder clean URLs sind URLs, die sowohl von Menschen als auch von Suchmaschinen verstanden werden. Sie bilden den Pfad zu der aufgerufenen Seite ab. Seit Version 1.5 kann Joomla! URLs in verschiedenen Formaten erzeugen und parsen, darunter auch SEF URLs. Dabei ist Joomla nicht vom URL-Rewriting (Apache mod-rewrite Modul) des Webservers abhängig. SEF URLs können auch auf jedem Nicht-Apache-Server generiert werden. SEF URLs haben ein feststehendes Muster. Der Benutzer kann jedoch kurze, beschreibende Texte (Aliase) für jeden Teil der URL definieren.

Intern wird der lokale Teil der SEF URL (der Teil des Domain Namens) eine Route genannt. Das Erzeugen und Verarbeiten von SEF URLs wird daher als Routing bezeichnet. Der dazugehörige Code wird Router genannt.

Das Verfahren zum Aktivieren von suchmaschinenfreundlichen URLs unterscheidet sich je nach dem verwendeten Webserver. Wenn Shared Hosting verwendet wird, handelt es sich vermutlich um Apache. Weitere Informationen gibt der Hosting-Provider, falls Zweifel bestehen.

Only the most popular web servers have been included on this page. Visit Enabling Search Engine Friendly (SEF) URLs on IIS and Category:Search Engine Friendly URLs for more articles.

Apache

Verify .htaccess is Enabled

Check that your Apache config file allows .htaccess overrides. You must make sure overrides are enabled or the .htaccess file in your Joomla! root directory will be ignored or cause an error. In the <Directory> section of your virtual host configuration file or in the main (httpd.conf) configuration file you must have something similar to the example below enabling overrides:

<Directory "/home/user/public_html">
  AllowOverride All
</Directory>

<Directory "/path/to/htdocs">
  AllowOverride All Options=[an option],[an option],...
</Directory>

There are other ways to test if .htaccess is enabled if you do not have access to your site's configuration files. Please refer to the .htaccess tutorial found on The Apache Software Foundation website for additional information.

Step by Step

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.

  1. Rename the file "htaccess.txt" in your Joomla!'s base folder to ".htaccess".
  2. This step may not be necessary. Open .htaccess in a text editor. Uncomment RewriteBase / (remove the first character, #). If Joomla is installed in its own folder, the enter the Joomla folder name after the forward slash. e.g. RewriteBase /yourjoomlafolder.
  3. Log on to your Back-end and open the Global Configuration.
  4. Enable the Use Apache mod_rewrite/URL rewriting 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:
    http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla
    If this option causes errors, please see How to check if mod rewrite is enabled on your server.
    • If it is not enabled and you have access to the file apache/conf/httpd.conf, open that file and check if the line LoadModule rewrite_module modules/mod_rewrite.so is uncommented. If necessary, uncomment the line and restart the Apache web server.
    • If mod_rewrite cannot be enabled, leave this option off. It does not matter if you leave the .htaccess file renamed.
  5. If you think this necessary, enable Add suffix to URLs and Save. This option adds .html 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 .html or not.
  6. 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.


Hiawatha

<translate> Use the following UrlToolkit rule to enable clean URLs on the Hiawatha webserver:</translate>

UrlToolkit {
    ToolkitID = joomla
    Match base64_encode.*\(.*\) DenyAccess
    Match (<|%3C).*script.*(>|%3E) DenyAccess
    Match GLOBALS(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
    Match _REQUEST(=|\[|\%[0-9A-Z]{0,2}) DenyAccess
    RequestURI exists Return
    Match /index.php Return
    Match ^/component/ Skip 2
    Match ^(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ Skip 1
    Skip 1
    Match .* Rewrite /index.php
}

<translate> Enable an UrlToolkit rule for a virtual host via the UseToolkit setting:</translate>

VirtualHost {
    ...
    UseToolkit = joomla
}


IIS 7

<translate> If you have a server running IIS 7 and PHP, you can take advantage of IIS's own internal URL rewriting by using a web.config file similar to the one listed below.</translate>

<translate> You can create the file yourself or use the GUI in the IIS7 Manager. You can import .htaccess rules using the GUI/wizard.</translate>

<translate> This functionality depends on the presence of the IIS URL Rewrite Module, which does not come with Windows. It is a free download and a Microsoft product.</translate>

<translate> ===GUI=== </translate> <translate> If the IIS URL Rewrite module is installed, your website manager will have a tool for URL Rewrite, visible in the IIS Manager's view of your site's configurable IIS modules. The interface is largely self-explanatory. Regular expressions, wildcards or exact matches are all supported.</translate>

<translate> In the Joomla config turn on both the SEF and Apache mod_rewrite. Next create a rule under IIS URL Rewrite:</translate>

Pattern field: ^([^/]+)/?$
Ignore case ON
Action type: Rewrite
Rewrite URL: index.php/

<translate>=== web.config === </translate> <translate> This has been tested on Joomla 1.5 with IIS 7 on Windows Server 2008 with no problems so far. For more information on converting .htaccess to web.config, see Translate .htaccess Content to IIS web.config</translate>

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Common Exploit Blocking" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" />
                        <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" />
                        <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" />
                        <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" />
                        <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" />
                    </conditions>
                    <action type="Redirect" url="index.php" appendQueryString="false" redirectType="SeeOther" />
                </rule>
                <rule name="Joomla Search Rule" stopProcessing="true">
                    <match url="(.*)" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^/search.php" ignoreCase="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php?option=com_content&amp;view=article&amp;id=4" />
                </rule>
                <rule name="Joomla Main Rewrite Rule" stopProcessing="true">
                    <match url="(.*)" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="(/[^.]*|\.(php|html?|feed|pdf|raw))$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/" />
                </rule>
            </rules>
        </rewrite>
        <caching>
            <profiles>
                <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
            </profiles>
        </caching>
    </system.webServer>
</configuration>


Nginx

<translate>

  • Please add this code to your server (vhost) configuration in the nginx.conf file:</translate>
   # <translate>Support Clean (aka Search Engine Friendly) URLs</translate>
   location / {
      try_files $uri $uri/ /index.php?$args;
   }

<translate>

  • If the above does not work, add this code to your server configuration in the nginx.conf file: (This worked with nginx 1.4.6 on Ubuntu.)</translate>
server {
  ....
  location / {
     expires 1d;

     # Enable joomla SEF URL's inside Nginx
     try_files $uri $uri/ /index.php?$args;
  }
  ....
}

<translate>

  • Log on to your Backend and open the Global Configuration.</translate>

<translate>

  • Enable the Search Engine Friendly URLs option and Save. This option converts the URLs from the native Joomla! format to the SEF format.</translate>

<translate>

  • Verify that your site works correctly. Your URLs should now look like https://www.example.com/index.php/the-­news/1-­latest­-news/1­-welcome­-to­-joomla.</translate>

<translate>

<translate>

  • Enable the Use Apache mod_rewrite/URL rewriting option and Save. This option uses the Apache mod_rewrite function to eliminate the index.php portion of the URL</translate>

<translate>

  • Verify that your site works correctly. Your URLs should now look like https://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla.</translate>

<translate>

<translate>

  • If it is not enabled and you have access to the file apache/conf/httpd.conf, open that file and verify that the line LoadModule rewrite_module modules/mod_rewrite.so is uncommented. If necessary, uncomment the line and restart the Apache web server.</translate>

<translate>

  • If mod_rewrite cannot be enabled, leave this option off. It does not matter if you leave the .htaccess file renamed.</translate>

<translate>

  • If you think this is necessary, enable Add suffix to URLs and Save. This option adds .html 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 .html or not.</translate>

<translate>

  • 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.</translate>