How to implement search engine-friendly urls

# Clean URLs with Apache .htaccess

Tiki supports search-engine friendly web addresses (SEFURLs or clean URLs), 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 clean URLs so that such short URLs will bring up a Tiki page, and by configuring Tiki properly, Tiki will produce clean URLS and build them into menus, static links, etc. This page explains both steps: how to make Tiki understand and produce clean URLs. See also: htaccess

## Examples

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

Notice how any text after http://info.tiki.org/article192-Tiki will work, such as http://info.tiki.org/article192-Tiki-Passes Thus, the article title can be modified and the URL still works. Canonical URLs are there to inform search engines of the correct one.

#### Note

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

## How to Activate Clean URLs

There are two basic steps to activivating Clean URLs:
1. Activating input rewrite rules on your server (so Tiki can understand clean URLs)
• With this step alone, accessing your site with clean URL short links will work properly
2. Enabling the SEFURL or SEFURL Filter (version 3.0) feature (or both) in Tiki (So Tiki will produce clean URLs)
• This causes internal Tiki links to be rewritten into clean URLs. The generation of the clean URLs is governed with 'output rewrite rules' that are in the code before Tiki 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 Tiki 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

<Directory "/">
...
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:

AllowOverride All

#### 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 Tiki that pull into the .htaccess file automatically when the steps above for Apache web servers are followed.

[+]

### Step 2: Configure Tiki to Produce Clean URLs

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

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:

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 engine friendly url
Selecting the first checkbox will activate the SEFURL feature within Tiki, meaning that some links used in and elsewhere in Tiki 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'.

Within Tiki,
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:

## 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 Tiki, you must adapt the input rewrite rules
• Starting with Tiki 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's Corner

The 'on the fly' filter can use 2 smarty tools: prefilter and a function. Here's an example:
<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.

## Alias

Short URL | Short URLs | ShortURL | ShortURLs | ModRewrite | Mod_Rewrite | SEFURL | SEFURLs | Friendly URL | Friendly URLs | Clean URL | Rewrite Rules | Rewrite Rule | Clean URLs

### Keywords

Keywords serve as "hubs" for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):

Accessibility (WAI and 508)
Accounting (7.x)
Articles and Submissions
Banners
Batch (6.x)
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Clean URLs
Communication Center
Compression (gzip)
Content Templates
Contribution (2.x)
Credit (6.x)
Date and Time
Debugger Console
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
Draw 7.x
Dynamic Content
Dynamic Variable
External Authentication
FAQ
File Gallery
Forum
Friendship Network (Community)
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
Kaltura video management (4.x)
Karma
Live Support
Logs (system & action)
Look and Feel
Lost edit protection
Mail-in
Map with Mapserver
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Payment
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Report
Toolbar
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Search and Replace
Security
Share
Shopping cart
Shoutbox
Slideshow
Smiley
Social Networks
Spam protection (Anti-bot CATPCHA)
Spellcheck
Stats
Surveys
Tags (2.x)
Tell a Friend, alert + Social Bookmarking
TikiTests (2.x)
Theme CSS & Smarty
Trackers
Transitions (5.x)
TRIM
User Administration including registration and banning
User Files
Watch
WebHelp
WebDAV (5.x)
Webmail
Web Services
Wiki 3D
Wiki History, page rename, etc
Wiki Page Staging and Approval (2.x)
Wiki Plugin extends basic syntax
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WSOD
WYSIWYCA
WYSIWYG (2.x)
XMLRPC