Manual:Short URL/Apache/fr

Ces instructions permettent de créer et paramétrer des URLs courts ("short URL") sur Apache. Le serveur internet LiteSpeed est compatabile avec Apache et peut être configuré d'une manière relativement proche. Pour connaître l'utilité des URLs courts ou pour obtenir des instructions sur leur configuration à partir d'autres serveurs, consulter Manual:Short URL. Si vous ne connaissez pas quel serveur internet vous utilisez en raison d'un recours à des services d'hébergement internet, il y a de fortes chances pour que votre hébergeur utilise Apache.

Plan
Avant tout, choisir le nom du chemin virtuel "short url".

Dans ce manuel, nous recommandons / supposons le suivant. Utiliez votre propre nom de chemin s'il est différent.
 * Le dossier MediaWiki est localisé dans :
 * Le format "short url" désiré est :

Les instructions suivantes ont été inclues dans un wizard automatique (qui nécessite MediaWiki 1.17 ou toute version postérieure):
 * http://shorturls.redwerks.org/

Si vous voulez juste une configuration rapide de votre wiki ou si vous trouvez le guide quelque peu confus, alors vous pouvez vouloir utiliser cet outil en premier. Cependant, notez qu'il ne fonctionnera pas sur des wikis protégés par un parefeu ou sur des wikis privés. Dans le dernier cas, vous pouvez toujours essayer en mettant votre wiki en mode temporairement publique à l'aide du réglage  to. N'oubliez pas de le changer de nouveau en  une fois la tentative terminée.

Sinon, suivez les instructions suivantes.

Trouver le bon fichier
The recommended way to set up short URLs in Apache is by editing the Apache config files. This requires that you have access to the server configuration. If you are on a shared host, you most likely don't and will need to use a  file instead. Using  files is less efficient and doesn't give you as much control when it comes to fancy setups with multiple domains but they are powerful enough to set up most short url configurations. LiteSpeed users should use the  method.

Use the instructions of one of the following two sections, depending on whether you have root access or need to use  instead.

Trouver le fichier de configuration Apache (root access)
Le fichier de configuration correct pour pour éditer les configurations du root peut se trouver dans divers dossiers.

La plupart des distributions linux permettent d'effectuer le setup de Apache avec  folders setup. The correct config file to edit is the one in  where the configuration for your wiki has been setup. If you haven't set one up and are using the default  for your wiki setup then you can edit.

Don't forget to enable overrides by. It is disabled by default in Ubuntu 12.04 and Ubuntu 12.10.

If your distribution does not have those directories, then you should edit the Apache configuration file directly. This file should be at. Note that it used to be named, if you have a   and no   then   is the one you want to edit.

If your Apache config isn't in any of these spots you should consult the documentation for whatever system you used to install Apache, and find the location of the Apache configuration file.

If you're on a shared host without access to Apache config files you'll have to use a .htaccess file instead.

In an Apache config file you will likely have a VirtualHost block containing your wiki. If you do have one then that is the location where your rewrite rules will go. RewriteRule config does not inherit so don't put these config options in the global config if you are using a VirtualHost.

After you've setup the config as below inside Apache you're going to need to restart Apache to make it apply the new config.
 * If you are using Plesk or cPanel it should have a method of restarting the server.
 * From the command line the command is usually something like,  ,   or as on the latest Fedora releases  . These commands need to be run as root, usually by prefixing them with.

Where to put .htaccess
If you're using a  file you'll need to edit or create the file. Find the path that contains both your script path and your virtual path. Usually this means the top directory of your site, but let's look at a few examples:

Note that if you want to make a redirect from the main domain to your wiki's Main Page (e.g. http://example.org/ &rarr; http://example.org/wiki/Main_Page ). Then you always have to set up the .htaccess file in the top level, even if the other directories are nested deeper.

Setting up the rewrite rules
The first rule you'll need inside of your config is one to enable the rewrite engine:

Now we need a rule to make your article path a virtual path pointing to index.php. Be sure to replace  and   with the paths you choose in the beginning (if different).

If you are using a root url instead of a normal short url you will need to use the following instead (to ensure that existing files and directories are not seen as article, e.g. "/index.php" "/images" etc.):

Optionally, you can include a rule to show the Main Page on the path itself, to simplify navigation when people visit urls without a page title specified:

The end result should look something like this:

LocalSettings.php
We need to make the following configurations in LocalSettings.php:

If you get an "Internal error" page saying "Redirect loop detected!" after you finish configuration you may be using something other than mod_php. If so you need to explicitly turn on short urls using the following line in your LocalSettings.php: