[Show/Hide Right Column]

noteNote
This page is to document what Tiki does. For feature requests and bug reports, please see corresponding page on dev site

How to implement search engine-friendly urls
Print

Clean URLs

Tiki supports search engine friendly URLs (SEFURLs), which are short versions of Tiki URLs thanks to Apache Rewrite Rules. Some search engine crawlers do not process links with trailing parameters, so transforming the syntax makes the URL more search engine friendly. By configuring your server properly, Tiki can understand SEFURLs so that such short URLs will bring up a Tiki page, and by configuring Tiki properly, Tiki will produce SEFURLS and build them into menus, static links, etc. This page explains both steps: how to make Tiki understand and produce SEFURLs.

Examples

Here are some examples of how SEFURLs work for various types of Tiki pages:

Type of PageSEFURLLong URL
Wiki pagehttp://tikiwiki.org/TikiWikiRewriteRule http://tikiwiki.org/tiki-index.php?page=TikiWikiRewriteRule
Forumhttp://tikiwiki.org/forum4 http://tikiwiki.org/tiki-view_forum.php?forumId=4
Articlehttp://tikiwiki.org/art133 http://tikiwiki.org/tiki-read_article.php?articleId=133
Articlehttp://tikiwiki.org/art133-This-is-the-title-of-the-article

Note that both the short and long URLs will still access your site.

How to Activate Search Engine Friendly URLs

There are two basic steps to activiating SEFURLs:

  1. Activating input rewrite rules on your server (so Tiki can understand SEFURLs)
    + With this step alone, accessing your site with SEFURL links will work properly
  2. Enabling the SEFURL or SEFURL Filter (version 3.0) feature (or both) in TikiWiki (So Tiki will produce SEFURLs)
    + This causes internal TikiWiki links to be rewritten into SEFURLs. The generation of the SEFURLs is governed with 'output rewrite rules' that are in the code before TikiWiki version 3.0 and in the database beginning with 3.0.

Step 1: Activate Input Rewrite Rules on Your Server

Web Hosting Service Using Apache

If you have TikiWiki version 1.9.x or greater and are using a web hosting service that uses Apache, then input rewrite rules can be activated as follows:

  • Rename the file named _htaccess in your Tiki root directory to .htaccess (or create a symbolic link to .htaccess).
    • This will automatically bring in suggested rewrite rules shown below (at Suggested Input Rewrite Rules ) into the .htaccess file. The _htaccess file is included as part of the Tiki download (since version 1.9.3) but is not activated by default because it may not work with all server configurations.

Apache Configuration When Managing Own Server

If you manage your server and are using Apache, be sure to

  1. Load the rewrite module. Something like this line in httpd.conf: LoadModule rewrite_module modules/mod_rewrite.so (adjust the path if necessary). You can check it is ok if you see the mod_rewrite in the apache loaded modules.
  2. Enable the access to .htaccess. To do so you must have lines like

Image

<Directory "/">
...
Options FollowSymLinks
AllowOverride FileInfo
...  
</Directory>
Adapt the directory path to your need. This block can be in httpd.conf or in your virtual host config(vhosts.d directory in apache2)

The documentation for Apache2 core says that the <FilesMatch> section requires: Image

AllowOverride All

3. Restart your server

Web Servers Other Than Apache

If you or your web hosting company is using a web server other than Apache (IIS for example), see your server manual or contact your web hosting service to find out how to activate rewrite rules on your server.

Suggested Input Rewrite Rules

Below are the rewrite rules for different versions of TikiWiki that pull into the .htaccess file automatically when the steps above for Apache web servers are followed.

3.x version

[+]

Step 2: Configure Tiki to Produce SEFURLs

Now that your input rewrite rules have been set, you now need to configure TikiWiki to activate the output rewrite rules so that TikiWiki will generate SEFURLs internally in menus, static links and elsewhere.

Before Version 3.0

Within TikiWiki,

  1. Go to Admin Home -> Features -> Experimental -> Search engine friendly url (checkbox)
    + Or use the following URL to get to the Features page (since version 2.0): your URL/tiki-admin.php?page=features
  2. Check the box for "Search engine friendly url" to select this feature
  3. Click "Apply" to activate the feature
    Here's a screenshot:


Experimental tab of Features page (version 2.2)
Image

Version 3.x

Starting with version 3.0, there is a search engine friendly feature icon directly on the Admin Home page that will look something like this:

Admin Icon (version 3.0)
Image

Clicking on that icon will bring up the search engine friendly url admin page (although you could reach this page through the paths described above for previous versions as well):
Search enginge friendly url admin page (version 3.0)
Image

  • Search engine friendly url - Selecting the first checkbox will activate the SEFURL feature within TikiWiki, meaning that some links used in and elsewhere in TikiWiki will be search engine friendly. This doesn't work for all links because not all of the templates have been updated, that's why there is a second checkbox...
  • Search engine friendly url Postfilter - To generate SEFURLs for all Tiki links, also check the second checkbox which creates short URLs by filtering the output. The SEFURL Postfilter consumes more processor (CPU) time than the non-filter version (it deals with all the text and it deals also with cached text like modules while the 'on the fly' filter does not do it. In future versions the SEFURL Postfilter will not be used - it is only necessary until the template SEFURL work is finished. Either one or both features (SEFURL and SEFURL Postfilter) may be used.
  • List of Url Parameters that should go in the path - This is used if you want a post or get variable to be represented in the sefurl. For instance if you have a url like tw.org/tiki-index.php?page=xxx&lang=en and if you put lang in the setting, the sefurl will be tw.org/en/xxx. You can generalize to any number of parameters. For a setting lang,locale, an url tw.org/tiki-index.php?page=xxx&lang=en&locale=us, the sefurl will be tw.org/en/us/xxx. This setting requires you adapt your .htaccess.
  • Display article title in the sefurl - Clicking this checkbox will add the title of the article to the url for a link to that article. For instance, tiki-read_article.php?articleId=1 will be transformed into article1-My-article-title. This does not work with the postfilter, only with 'on the fly filter'.
  • Display blog title in the sefurl - Similar to the article checkbox, clicking this checkbox will add the title of the blog to the url for a link to that blog. This does not work with the postfilter, only with 'on the fly filter'.

Changing Rewrite Rules

You can customize the rewrite rules but it is important to note that that the input and output rewrite rules are connected, so that if you change one you may need to change the other.

  • You can add as many input rewrite rules you want. For instance if you want to be able to access a forum with forum1 or forum_1, no problem. Add the adequate rule in the htaccess that will rewrite forum_1 to tiki-view_forum.php?forumId=1
  • But if you want to change the output "rewrite" rules in tikiwiki, you must adapt the input rewrite rules
  • Starting with TikiWiki version 3.0, the output rewrite rules are in the table tiki_sefurl_regex_out

WARNING: For sites hosted with MediaTemple's (gs) Grid-Service

After making these changes, your site may mysteriously revert back to using PHP4. This will result in an error such as the following when you try to access your site:

Parse error: syntax error, unexpected T_STRING, expecting '{' in /nfs/c03/h01/mnt/GRID#/domains/YOURSITENAME.COM/html/tiki-install.php on line 45

Resolve this by logging into the MediaTemple control panel and switching the site back to PHP5. Afterwards, double-check that your Search Engine Friendly url is still enabled in TikiWki.

Developer corner

The 'in the fly' filter can use 2 smarty tools. A prefilter and a function

  • exemple

<img src="{$fileId|sefurl:thumbnail}" />
<a href="{sefurl page=$next_info.pageName structure=$home_info.pageName page_ref_id=$next_info.page_ref_id}">
<a href="{$listpages[ix].articleId|sefurl:article:with_next}show_comzone=y#comments">
Both filters use tiki-sefurl.php to rewrite the urls.

Related

Alias


Contributors to this page: KMull124 points  , xavi36278 points  , system , sylvie4333 points  , Scot Wilcoxon680 points  , Mose96 points  , mlpvolt1895 points  , Marc Laporte5511 points  , luciash d' being1589 points  , lindon2331 points  , Gérald Pineau6 points  and Damian Parker14 points  .
Page last modified on Friday 04 June, 2010 20:43:30 UTC by KMull124 points .

Find by Page Name

Exact match

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki documentation and should correspond to development keywords (bug reports and feature requests):