Using personalised URLs

After installation, pages generated with SPIP use relative addresses of the form spip.php?article765, which results in URLS like http://www.spip.net/spip.php?article765.

There is a possibility to have addresses more to your taste if you choose — for example article123.html or Title-of-the-article.html, and SPIP helps you with a portion of this task.

This feature uses the distinction between two types of URLs:

-  the apparent URL of a page, being what you typed into or what is displayed in the address bar of your navigator. For example, http://www.spip.net/fr_article3588.html. These are the URLs that people often want to make "prettier" or "more meaningful" ;

-  the real URL of the page, being the URL that is "seen" by SPIP whenever the page is calculated on the server. For example, http://www.spip.net/spip.php?article3588 ;
is typical, and this URL can also be typed directly into the navigator
(you can confirm this).

Selecting the type of URLs

Go to Configuration → Setup the URLs and choose the preferred URL type.

It is also possible to force the address type from the file config/mes_options.php

$type_urls = "propre";

Programming the translation of apparent addresses into real addresses

So that the address article123.html actually calls the PHP spip.php file with id_article=123 as a parameter, it is necessary to configure the Web server that is hosting your site, be that with the .htaccess file (which is not always possible), or by editing the the central server configuration file if you have access to it. This technique uses, on Apache servers (the most common), what are known as Rewrite Rules : rules for rewriting Web addresses.

Knowing how to write these rules is not a simple matter for non-programmers, and we can’t give you solutions guaranteed to work because it depends a lot on your configuration : this component is entirely in your own hands and responsibility (or that of your host).

Nevertheless, SPIP is supplied with an htaccess.txt file as an example, which works with most server hosts for the types of URL referred to above («standard», «html», «propres» and «propres2»). To activate it, it is necessary to recopy it to the site root directory, renaming it .htaccess. It is highly advised to open the file first to verify certain items of configuration.

You should then test the validity of the new address, by calling the "View on line" page of an article, an author, a news item, a section, etc.

Generating apparent URLs in the SPIP pages

In order to display the URLs according to the schema you have chosen, your templates should use the following tags: #URL_ARTICLE, #URL_RUBRIQUE, #URL_BREVE, etc.

Transitioning from one type of URL to another

Everything has been prepared so that transitioning from one type of address to another can be done in complete confidence: install the htaccess.txt file, and you can then freely switch from "standard" addresses to "propres2" or "html" addresses, and vice versa, without provoking 404 errors for site visitors (of for search engines) that have memorised, indexed or bookmarked the presvious addresses.

As a last mention to make transitioning easier, if you select propres or propres2 URLs, visiting pages that carry the previous type of address (standard or html) are automatically redirected to the new addresses.

Author Mark Published : Updated : 27/12/22

Translations : عربي, català, English, Español, français, italiano, Nederlands, slovenčina, українська