Manual:Short URL/fr

Les URLs courtes ou les réécritures d'URL masquent l'adresse des pages des fichiers php. Veuillez prendre quelques minutes pour concevoir une structure stable d'URL pour votre site avant de commencer afin de limiter les problèmes à l'avenir.

Objectif
Le chemin d'installation par défaut de MediaWiki ressemble généralement à ceci :
 * (installé en tant que root)
 * (installé avec un fournisseur d'hébergement partagé)

Les adresses de page par défaut de MediaWiki ressemblent à ces exemples :
 * (les versions récentes de MediaWiki, sans le support CGI)
 * (recent versions of MediaWiki, with CGI support)

En utilisant les méthodes décrites sur cette page, nous pouvons obtenir des configurations comme celles-ci :
 * Il s'agit de la configuration la plus courante, comme dans Wikipedia, mais pas par défaut car elle nécessite des modifications côté serveur
 * '(non recommandé ! voir ci-dessous)'
 * '(non recommandé ! voir ci-dessous)'
 * '(non recommandé ! voir ci-dessous)'
 * '(non recommandé ! voir ci-dessous)'

Remarque : Avoir le nom de la page à droite dans la racine du nom de domaine n'est pas recommandé, car il sera en conflit avec les fichiers et répertoires situés dans le répertoire racine. Par exemple, si vous avez vos images dans le répertoire /images/, vous ne serez pas en mesure d'accéder à une page nommée "Images" dans votre wiki.

Avantages & désavantages

 * Advantage: Short URLs hide some technical details from end-users, which can be desirable for site owners. Among other things, this means they can be kept stable when the underlying software changes. (See above for the difference between MediaWiki's default URL structure with CGI enabled vs without). Elles sont également plus faciles à lire, mémoriser et manipuler pour les visiteurs. Additionally, short URLs offer an advantage over the default URLs for Search engine optimization, as URLs containing  can be treated less favorably by search engines when calculating page rank.
 * Désavantage : nécessite une configuration. Donc en fonction de l'environnement d'hébergement que vous utilisez, cela peut être difficile à recréer. However, as every widely used webserver is capable of being configured to use short URLs, most paid web hosting services should support this feature. Any host that doesn't offer you this feature is not worth your money.

Guides
Nos guides officiels pour la configuration d'URL courte pour différents serveurs web. Choisissez la configuration de votre serveur web à partir de cette liste. Si vous ne savez pas quel logiciel serveur est utilisé, le plus probable est Apache



Other how-to mini-guides

 * These guides are old and are almost entirely bad advice. These will eventually be deleted one by one as our official guides above are created for different webservers.

Anyone is welcome to create a how-to solution page and list it below. Please use a sensible name for the page, one that fits in with the below names. When each unique solution has its own page, readers can skip complexity they do not want. Keep it simple, readable, short, with a separate page per separate solution.

To help others find out which Short URL methods really work, after trying each method please edit the page and increase the "worked" or "didn't_work" numbers for that guide and make a brief (or long, your choice) description on what went wrong by clicking the link on your number.

URL like - example.com/wiki/Page_title
Actions such as edit, view history, etc. will still have index.php unless $wgActionPaths are defined.

Root access
These methods require that you have access to the server configuration. If you are on a shared host, you most likely don't. In this case you will be required to use a method that requires "no root access". You can jump directly to the MediaWiki ShortURL Builder tool and follow the on screen instructions after clicking on "I don't have root access".

* Abyss Web Server X2

(for Apache guidance, see the link in the Guides section).

URL like - example.com/Page_title
How to create example.com/Page_title URLs:

URL like - wiki.example.com/Page_title
How to create wiki.example.com/Page_title URLs.

Problème d'esperluette (&)
Le problème "esperluette" apparaît lorsque vous avez des titres de page avec des symboles (tels que &, ?, #, + et /) qui en dépit d'être correctement encodés dans le lien ne sont pas correctement passés par mod_rewrite vers le script. Cela se manifeste par l'affichage d'erreurs 404 page-not-found, parce que le titre est coupé au caractère spécial. Par exemple, en cliquant sur le lien "la page de John & Maria" vous obtenez un 404, parce que MediaWiki est à la recherche d'une page nommée "John".

This is because ampersands in long-form names are treated as query string separators, and would never reach the PHP runtime environment. Ceci est causé par un vieux et problématique bogue de mod_rewrite.

Solutions:

Le problème & est causé par  dont les règles de réécriture donnent   qui est complètement inutile et nuisible. MediaWiki analyse les chemins directement à partir de REQUEST_URI afin de tout réécrire vers /index.php.

Pas de Skins
With Ubuntu 8.10 and MediaWiki 1.11.2 (and maybe later versions) if you use the MediaWiki sanctioned directions your skins may fail to load. To fix this, create a symbolic link in /var/www pointing to /var/lib/mediawiki with the value of $wgScriptPath in LocalSettings.php. If, for example, $wgScriptPath is set to "/w" then you need to run the command "sudo ln -s /var/lib/mediawiki /var/www/w".

Alternatively, try setting $wgLoadScript to the original file. If you source url is /wiki with the short url /w, set it to /wiki/load.php.

Purge du cache
If you notice that your changes to  in LocalSettings.php are not being reflected in mysite.com/wiki/Main_Page, it may be due MediaWiki's caching of the links according to previous settings.

Go to mysite.com/wiki/Main_Page?action=purge to force MediaWiki to regenerate the cached links.

Also you can:
 * 1) execute the MySQL query "TRUNCATE objectcache;", or
 * 2) Ensure  is updated (if  is enabled all you have to do is edit LocalSettings.php to purge it)

Rediriger un visiteur de votre domaine vers votre wiki
Our official guides for short url configuration include recommendations on how to point the root of your site to your wiki using your short url config.

For example our Apache guide recommends using this to point your site root to your wiki:

Note that we do not recommend doing a HTTP redirect to your wiki path or main page directly. As redirecting to the main page directly will hard-code variable parts of your wiki's page setup into your server config. And redirecting to the wiki path will result in two redirects. Simply rewrite the root path to MediaWiki and it will take care of the 301 redirect to the main page itself.

If using VirtualHosts, place the rewrite rules into the virtual host declaration!

Déplacer un wiki depuis /wiki vers /w
A common beginner's mistake is to install MediaWiki itself (the source code, not the short url) in  instead of. Once installed they would realize the mistake when trying to configure Short URLs (which would become difficult as the virtual path then conflicts with the real path).

There is a manual for moving a wiki in general, however that is too complicated if all you need is to change the installation directory (and stay on the same server, same database and same hostname).

Here is what you have to do:


 * Backup  and any other config files you may have created (such as your  ).
 * Rename the installation directory of MediaWiki on your server from  to.
 * Set  in   to   and remove (or comment out) any definition of   (this variable will be changed again when setting up Short URLs, further on)
 * At this point your wiki should be working normally at
 * Now go through the regular guide to set up short URLs
 * Perform a few tests on your wiki to make sure nothing is broken. Edit a page, visit a few different pages, etc. If anything seems abnormal, revert the changes by restoring your backup of  and other relevant files you might have changed during configuration of short URLs and rename your folder back to.

Note for shared hosting users: Many shared hosting plans offer an application manager to automatically Install, Update and Backup applications such as MediaWiki. If your plan has this and if you want to keep using these features, you should contact their tech support and let them know you just manually changed your MediaWiki installation directory.

Voir également

 * Explanation of what CGI modules are
 * $wgUsePathInfo - configuration setting that defines whether to use 'pretty' URLs or not
 * Notes on placing your wiki installation in site root directory
 * $wgActionPaths - configuration setting that you can use to define 'pretty' URLs for other actions, like edit or history
 * Clean up URLs RFC - proposes "cleaner URLs for editing, previewing skins, etc."

Liens externes

 * Apache Module mod_rewrite at Apache.org
 * MediaWiki Short URL Builder Tool - A tool that can automatically generate short url configuration more reliable than the configurations in these manual pages.