Project

General

Profile

Actions

UrlRewriting

Pour la version 2.0.x et plus

Le moteur de réécriture utilise mod_rewrite du server Apache. Les règles sont contenues dans le fichier /public/.htaccess.
Au besoin (et en fonction de votre configuration) précisez la valeur de RewriteBase. Si votre installation se situe dans un sous-dossier, entrez la valeur RewriteBase/sous-dossier/public/.


###############
# Set RewriteBase to your folder.
# If set to root folder RewriteBase just takes '/public/' value
###############

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase /public/

  # if the requested path is a real file or directory, we don't rewrite anything
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Match http://localhost/linea21//actualite.html
  # Pattern : $_REQUEST['rub']  .html
  RewriteRule ^([a-zA-Z0-9-]*)\.html$  index.php?rub=$1 [L]

  # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id']  .html
  RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)\.html$  index.php?rub=$1&id=$3 [L]

  # Match http://localhost/linea21//directory/-6-.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR [ $_REQUEST['debut']] .html
  RewriteRule ^([a-zA-Z0-9-]*)/-([0-9]*)-\.html$  index.php?rub=$1&debut=$2 [L]

      # Match http://localhost/linea21//tableau-de-bord/taux-daccroissement-de-la-population,22/1.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id'] $_REQUEST['parentid']   .html
  RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)/([0-9]*)\.html$  index.php?rub=$1&id=$3&parentid=$4 [L]

  # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional] $_REQUEST['id'] URI_SEPARATOR $_REQUEST['parentid'] URI_SEPARATOR $_REQUEST['parentparentid'] .html
  RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)/([0-9]*)\.html$  index.php?rub=$1&id=$3&parentid=$4 [L]

  # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id'] $_REQUEST['parentid']   .html
  RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)/([0-9]*)/([0-9]*)\.html$  index.php?rub=$1&id=$3&parentid=$4&parentparentid=$5 [L]

 # Match directory/@level/environnement,3.html
  # Pattern : $_REQUEST['rub'] URI_SEPARATOR @$_REQUEST['filter'] URI_SEPARATOR NAME , $_REQUEST['id'] .html
  RewriteRule ^([a-zA-Z0-9-]*)/@([a-zA-Z]*)/([a-zA-Z0-9-]*),([0-9]*)\.html$  index.php?rub=$1&filter=$2&id=$4 [L]

  # Match directory/@alpha/P.html
  # Pattern: $_REQUEST['rub'] URI_SEPARATOR NAME @$_REQUEST['filter'] URI_SEPARATOR $_REQUEST['id'] .html
  RewriteRule ^([a-zA-Z0-9-]*)/@([a-zA-Z]*)/([a-zA-Z0-9-]*)\.html$  index.php?rub=$1&filter=$2&id=$3 [L]

</IfModule>

Important : Si mod_rewrite n'est pas activé, vous avez la possibilité d'utiliser l'ancien système de réécriture d'URL. Pour cela, renommez le .htaccess en mod_rewrite.htaccess. et renommez le fichier php_rewrite.htaccess en .htaccess.

Pour les versions antérieures à la 2.0.x

Dans les versions antérieures à la v2.0.0, Linea21 permettait la réécriture d'URL par déclenchement d'une erreur 404 et d'une gestion par un script PHP (/public/rewrite.php). Contenu du .htaccess :

###############
# ErrorDocument has to be set to use PHP mod rewrite
# If not in use, you can just ignore that instruction
###############

ErrorDocument 404  /public/rewrite.php

Updated by Simon over 7 years ago · 1 revisions