Manual:Short URL/Apache/fr

Ces instructions vous aident à configurer les URLS courtes sous Apache. Le serveur web LiteSpeed est compatible avec Apache et peut être configuré de la même manière. Pour obtenir des informations sur ce que sont les URL courtes ou sur la configuration pour d'autres types de serveurs, voir. Si vous ne savez pas quel serveur web vous utilisez, il y a de fortes chances que votre hôte utilise Apache.

Configuration
Avant de commencer, vous devez décider quel forme d'URL courte vous souhaitez utiliser.

Dans ce manuel, nous recommandons et supposons ce qui suit. Rappelez vous d'utiliser vos propres chemins s'ils sont différents.


 * Le dossier MediaWiki est localisé sur :
 * Le format désiré d'URL courte est :

Les instructions suivantes ont été inclues dans un assistant logiciel automatique (requiert MediaWiki 1.17 ou ultérieur):


 * shorturls.redwerks.org

Si vous voulez juste configurer rapidement votre wiki ou si vous trouvez le guide déroutant, vous devriez d'abord essayer d'utiliser cet outil. Si vous faites cela, remarquez que vous aurez besoin d'éditer ou de créer un fichier .htaccess. Si vous le recréez, lisez la suite de l'article pour savoir où placer le fichier .htaccess; veuillez noter que ce fichier devra se trouver dans un dossier sensiblement différent de l'autre fichier à modifier (LocalSettings.php), qui se trouve dans répertoire d'installation (/w si vous avez suivi les recommandations MediaWiki). Notez aussi que l'utilisation de cet assistant ne fonctionne pas sur les wikis privés ou avec un parefeu. Dans ce cas, vous pouvez essayer de rendre temporairement votre wiki publique en initialisant  à. N'oubliez pas de le remettre à  lorsque vous aurez terminé.

Pour les autres cas, suivez les instructions ci-dessous.

Trouver le bon fichier
La manière recommandée pour déclarer les URLs courtes dans Apache se fait en modifiant les fichiers de configuration de Apache. Cela demande que vous ayez accès à la configuration du serveur. Si vous êtes sur un hôte partagé, vous ne l'avez probablement pas et vous devrez utiliser un ficher  à la place. 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. Les utilisatuers de LiteSpeed doivent utiliser la méthode.

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

Trouver le fichier de configuration Apache (accès root)
The correct configuration file to edit for root configurations may be in one of a number of places.

The correct config file to edit is the one in  where the configuration for your wiki has been setup.

Le plupart des distributions Linux configurent Apache en initialisant le contenu des répertoires  et. If you haven't set one up and are using the default  for your wiki setup then you can edit.

N'oubliez pas d'autoriser les réécrasements par  dans. Par défaut, il est désactivé dans Ubuntu 12.04 et Ubuntu 12.10.

If your distribution does not have those directories, then you should edit the Apache configuration file directly. Ce fichier doit être dans. 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.

Si vous êtes sur un hôte partagé sans accès aux fichiers de configuration Apache, vous devez utiliser un fichier  à la place.

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 above inside Apache you're going to need to restart Apache to make it apply the new config.


 * Si vous utilisez Plesk ou cPanel, ils doivent avoir une méthode pour redémarrer le serveur.
 * 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.

Où mettre .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/ 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.

Déclarer les règles de réécriture
It's easier to understand the rest of this section after a glimpse at the Apache syntax, but this synopsis is not a substitute for the full Apache documentation:

The  directive defines a condition that must be true before a RewriteRule that follows it may be applied. One or more RewriteCond directives may precede a RewriteRule directive, and all the RewriteCond directives that precede a RewriteRule must be true before that rule may be applied to a URI. In the examples that follow,  takes the form of a reference to server variables, e.g.  . Although many   exist, the examples that follow use   (true when TestString is a regular file) and   (true when TestString is a directory), and they are preceded by a negation symbol,.

The  directive may be invoked in both the   file and in any   file, but when the rewrite rule appears in .htaccess files, the implicit per-directory context affects the rule's   because rules are relative to the current directory. In  files, Patterns are not relative to the complete, original URI. For  files, Patterns should never start with a forward slash, , because the URI sub-string will never begin with a. The examples that follow use the  flag whose meaning is Stop the rewriting process immediately, and don't apply any more 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. " " " " etc.):

Sometimes, the above example doesn't work. The following (you can't set this in a, you need root access for this!) might work instead:

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:

Le résultat final devrait être similaire à ceci :

or, if you used the way with the "Alias" statement:

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

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:

If there is still an "internal error" check the log files of your server. Maybe you have to turn on  module.

Instructions rapides
The following is a summary of what to do if you are not doing anything different than what MediaWiki recommends. If you want to do something else, you need to read all of the details above.


 * https://example.com/wiki/Main_Page (emplacement de l'URL)
 * /home/me/public_html/mediawiki/w/index.html (emplacement de index.html)
 * /home/me/public_html/mediawiki/.htaccess (emplacement de .htaccess)

Notice that the .htaccess file is NOT located in the "w" directory, but it is located in the directory above it.