UrlRewriting » History » Version 1
Simon, 12/12/2016 09:08 AM
1 | 1 | Simon | h1. UrlRewriting |
---|---|---|---|
2 | |||
3 | |||
4 | h2. Pour la version 2.0.x et plus |
||
5 | |||
6 | Le moteur de réécriture utilise _mod_rewrite_ du server Apache. Les règles sont contenues dans le fichier _/public/.htaccess_. |
||
7 | 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/_. |
||
8 | |||
9 | |||
10 | <pre> |
||
11 | |||
12 | ############### |
||
13 | # Set RewriteBase to your folder. |
||
14 | # If set to root folder RewriteBase just takes '/public/' value |
||
15 | ############### |
||
16 | |||
17 | |||
18 | |||
19 | |||
20 | <IfModule mod_rewrite.c> |
||
21 | Options +FollowSymlinks |
||
22 | RewriteEngine On |
||
23 | RewriteBase /public/ |
||
24 | |||
25 | # if the requested path is a real file or directory, we don't rewrite anything |
||
26 | RewriteCond %{REQUEST_FILENAME} !-f |
||
27 | RewriteCond %{REQUEST_FILENAME} !-d |
||
28 | |||
29 | # Match http://localhost/linea21//actualite.html |
||
30 | # Pattern : $_REQUEST['rub'] .html |
||
31 | RewriteRule ^([a-zA-Z0-9-]*)\.html$ index.php?rub=$1 [L] |
||
32 | |||
33 | # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html |
||
34 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id'] .html |
||
35 | RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)\.html$ index.php?rub=$1&id=$3 [L] |
||
36 | |||
37 | # Match http://localhost/linea21//directory/-6-.html |
||
38 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR [ $_REQUEST['debut']] .html |
||
39 | RewriteRule ^([a-zA-Z0-9-]*)/-([0-9]*)-\.html$ index.php?rub=$1&debut=$2 [L] |
||
40 | |||
41 | # Match http://localhost/linea21//tableau-de-bord/taux-daccroissement-de-la-population,22/1.html |
||
42 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id'] $_REQUEST['parentid'] .html |
||
43 | RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)/([0-9]*)\.html$ index.php?rub=$1&id=$3&parentid=$4 [L] |
||
44 | |||
45 | # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html |
||
46 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional] $_REQUEST['id'] URI_SEPARATOR $_REQUEST['parentid'] URI_SEPARATOR $_REQUEST['parentparentid'] .html |
||
47 | RewriteRule ^([a-zA-Z0-9-]*)/([a-zA-Z0-9-]*),([0-9]*)/([0-9]*)\.html$ index.php?rub=$1&id=$3&parentid=$4 [L] |
||
48 | |||
49 | # Match http://localhost/linea21//actualite/ou-sarretera-letalement-urbain,5.html |
||
50 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR [NAME , -optional],$_REQUEST['id'] $_REQUEST['parentid'] .html |
||
51 | 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] |
||
52 | |||
53 | # Match directory/@level/environnement,3.html |
||
54 | # Pattern : $_REQUEST['rub'] URI_SEPARATOR @$_REQUEST['filter'] URI_SEPARATOR NAME , $_REQUEST['id'] .html |
||
55 | RewriteRule ^([a-zA-Z0-9-]*)/@([a-zA-Z]*)/([a-zA-Z0-9-]*),([0-9]*)\.html$ index.php?rub=$1&filter=$2&id=$4 [L] |
||
56 | |||
57 | # Match directory/@alpha/P.html |
||
58 | # Pattern: $_REQUEST['rub'] URI_SEPARATOR NAME @$_REQUEST['filter'] URI_SEPARATOR $_REQUEST['id'] .html |
||
59 | RewriteRule ^([a-zA-Z0-9-]*)/@([a-zA-Z]*)/([a-zA-Z0-9-]*)\.html$ index.php?rub=$1&filter=$2&id=$3 [L] |
||
60 | |||
61 | </IfModule> |
||
62 | </pre> |
||
63 | |||
64 | |||
65 | 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_. |
||
66 | |||
67 | |||
68 | h2. Pour les versions antérieures à la 2.0.x |
||
69 | |||
70 | 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_ : |
||
71 | |||
72 | <pre> |
||
73 | ############### |
||
74 | # ErrorDocument has to be set to use PHP mod rewrite |
||
75 | # If not in use, you can just ignore that instruction |
||
76 | ############### |
||
77 | |||
78 | |||
79 | |||
80 | ErrorDocument 404 /public/rewrite.php |
||
81 | </pre> |