URLs processing

You will have to configure SEF support manually only for existing projects (the Kernel module must be updated to version 5.1.8 or higher which enables UrlRewrite). New installations will have SEF support automatically configured.

URL Rewrite

UrlRewrite is used to enable a script to be accessible not only at its physical address, but also at any other address. For example, you can define such a UrlRewrite rule that a script /fld/c.php that can be accessed at /fld/c.php?id=15 will be called when a page /catalog/15.php is requested.

An address at which the script will be available may not physically exist on the server. In the address exists, the corresponding script will be called. URLRewrite will not be activated.

URL processing rules can be configured in the Control Panel (Settings -> System settings -> URL processing, /bitrix/admin/urlrewrite_list.php).

URLRewrite mechanism was created for use with Components 2.0 supporting SEF. However, it can be used to override any other URL's, not only with Components 2.0.

If a SEF-enabled component is added to a page and the page is saved using the editor API, a URL processing rule is created automatically. If the page is created otherwise (e.g. uploaded using FTP), you will have to create the rule manually.

Enabling URL processing

1. If you have the 404 error handler configured - for example, a ErrorDocument directive is specified for Apache in .htaccess:
     ErrorDocument 404 /404.php
you will have to edit /404.php by adding the following call at the beginning of the file:
 include_once( $_SERVER['DOCUMENT_ROOT']. '/bitrix/modules/main/include/urlrewrite.php' );

2. If you use mod_rewrite with Apache, you can specify the following settings (e.g. in .htaccess):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
</IfModule>

The settings will enable the regular SEF support mechanism for new components.

How to test your settings

1. Open Settings -> System settings -> URL processing in the Control Panel.

2. Click New record and add:
   Condition: #^/sef_test/#
   Compoment: empty
   File: /index.php (physically existing file)
   Rule: empty.
Save changes.

3. Open any page in /sef_test/(e.g. //localhost/sef_test/test.html).

If SEF functions properly, you should see the page specified in the File field of the rule.

Example of using SEF for news details page

The following rule will map pages whose names are the ID's of news (e.g. 234.html), to URL's with the ID parameter (e.g. detail.php?ID=234):

Condition: #^/news/([0-9]+)\.html(\?.*)?$
Rule: /about/news/detail.php?ID=$1

Opening a .php page when a .html file is requested

Sometimes, you may be forced to use .html extension for your pages. In this case, the rule may be the following:

Conditon: #^(.+)\.html(\?.*)?$#
Rule: $1.php

Processing old links

When you move information from an old site to a new one, you may want to retain links to critical pages that can be indexed by search engines or added to visitors' Favourites. These links require that you establish conditions that will map old links to new ones.

For example, the following rule can be defined for about.html:

Condition: #^/about.html(\?.*)?$#
Rule: /about/index.php