<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.code-web.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Code-Web.org - référencement</title>
  <link>http://www.code-web.org/</link>
  <description>Développement Web en toute liberté!</description>
  <language>fr</language>
  <pubDate>Mon, 08 Sep 2008 10:48:53 +0200</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>De belles URL sous Dotclear 2</title>
    <link>http://www.code-web.org/post/2008/03/31/Reecriture-dURL-sous-Dotclear-2</link>
    <guid isPermaLink="false">urn:md5:b73f58956a06c6ec421317c6b4fc5670</guid>
    <pubDate>Tue, 01 Apr 2008 07:10:00 +0200</pubDate>
    <dc:creator>Thierry Geindre</dc:creator>
        <category>Dotclear</category>
        <category>apache</category><category>dotclear</category><category>référencement</category>    
    <description>&lt;p&gt;On sait aujourd'hui que, pour un meilleur référencement, il est important d'utiliser des URL &lt;em&gt;human friendly&lt;/em&gt;. Vos visiteurs en seront ravis également. Pour cela, Dotclear vous propose les URL au format &lt;em&gt;PATH_INFO&lt;/em&gt;. Nous allons voir dans ce petit billet comment activer les URL au format &lt;em&gt;PATH_INFO&lt;/em&gt; et se débarrasser du vilain &lt;em&gt;index.php&lt;/em&gt;.&lt;/p&gt;    &lt;h3&gt;Réécriture d'URL&lt;/h3&gt;

&lt;p&gt;Ce premier paragraphe ne vous intéressera que si vous souhaitez utiliser la réécriture d'URL, c'est à dire faire disparaître le vilain &lt;em&gt;index.php&lt;/em&gt; de vos URL. Si ce n'est pas le cas, vous pouvez sauter au second paragraphe.&lt;/p&gt;


&lt;p&gt;Dans le répertoire contenant votre Dotclear 2, créez un fichier nommé &lt;em&gt;.htaccess&lt;/em&gt;. Placez-y le contenu suivant&amp;nbsp;:&lt;/p&gt;
&lt;pre&gt;
# Activation du moteur de réécriture
RewriteEngine on

# Si le fichier demandé n'existe pas physiquement
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# On envoie la demande à l'index de Dotclear
RewriteRule (.*) /index.php/$1 [L]
&lt;/pre&gt;


&lt;p&gt;Si votre Dotclear est situé dans un sous répertoire et que vous souhaitez que votre site soit accessible par un répertoire de plus haut niveau, vous devrez placer le fichier .htaccess que vous venez de créer dans ce répertoire de plus haut niveau puis remplacer la dernière ligne par ces &lt;strong&gt;deux&lt;/strong&gt; lignes&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
RewriteRule (.*) /sous-repertoire/index.php/$1 [L]
RewriteRule ^$ /sous-repertoire/index.php   [L]
&lt;/pre&gt;


&lt;p&gt;Enfin, pour que cela fonctionne, vous devrez également activer les URL au format &lt;em&gt;PATH_INFO&lt;/em&gt;.&lt;/p&gt;


&lt;h3&gt;Activer les URL au format &lt;em&gt;PATH_INFO&lt;/em&gt;&lt;/h3&gt;

&lt;p&gt;La première étape consiste tout naturellement à activer ce format d'URL. Pour ce faire, rendez-vous dans les paramètres du blog accessibles via le tableau de bord. Pour l'option &lt;em&gt;Méthode de lecture de l'URL&lt;/em&gt;, choisissez bien sur &lt;em&gt;PATH_INFO&lt;/em&gt;. Comme vous pourrez le voir dans l'aide, l'activation de cette option nécessite également que l'URL de votre blog, définit dans la même page de configuration, se termine par un /.&lt;/p&gt;


&lt;p&gt;Pour ce dernier paramètre, tout dépend de si vous souhaitez utiliser la réécriture d'URL ou pas. Si c'est la cas, vous pouvez indiquer une URL comme suit&amp;nbsp;: http://www.mon-site.com/ suivit d'un éventuel sous répertoire mais toujours terminé par un /.Si vous n'utiliserez pas de réécriture d'URL, saisissez une URL comme suit&amp;nbsp;: http://www.mon-site.com/index.php/ ou avec un sous répertoire&amp;nbsp;: http://www.mon-site.com/sous-repertoire/index.php/.&lt;/p&gt;


&lt;p&gt;Une fois cette nouvelle configuration enregistrée, vous devrez éditer le fichier &lt;em&gt;/inc/config.php&lt;/em&gt; de Dotclear et y dé commenter les dernières lignes suivant les indications que vous trouverez dans ce même fichier.&lt;/p&gt;


&lt;h3&gt;Des problèmes?&lt;/h3&gt;

&lt;p&gt;Assurez-vous d'avoir bien suivit toutes les indications données dans ce billet. Si c'est bien le cas, vous devrez aussi vous assurer que la réécriture d'URL (aussi appelé URL Rewriting) est disponible et active chez votre hébergeur. Vérifiez également que l'emploi de fichiers &lt;em&gt;.htaccess&lt;/em&gt; est permis.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.code-web.org/post/2008/03/31/Reecriture-dURL-sous-Dotclear-2#comment-form</comments>
      <wfw:comment>http://www.code-web.org/post/2008/03/31/Reecriture-dURL-sous-Dotclear-2#comment-form</wfw:comment>
      <wfw:commentRss>http://www.code-web.org/feed/rss2/comments/40</wfw:commentRss>
    						<h3>Abonnement aux commentaires</h3>
						<p>
							<a href="http://www.code-web.org/subscribetocomments?post_id=40">
								<!-- # If the subscriber is logged in -->
																<!-- # If the subscriber is not logged in -->
																	S'abonner pour recevoir les commentaires suivants par email															</a>
						</p>
					  </item>
    
  <item>
    <title>Évitez les URL multiples et le contenu dupliqué</title>
    <link>http://www.code-web.org/post/2008/03/09/50-evitez-les-url-multiples-et-le-contenu-duplique</link>
    <guid isPermaLink="false">urn:md5:9462aefff84dc422499d664661b4b28e</guid>
    <pubDate>Sun, 09 Mar 2008 16:12:00 +0000</pubDate>
    <dc:creator>Thierry Geindre</dc:creator>
        <category>Référencement</category>
        <category>apache</category><category>dotclear</category><category>référencement</category>    
    <description>&lt;p&gt;L'un des points nuisant au référencement est le contenu dupliqué ou &lt;em&gt;duplicate content&lt;/em&gt; dans le jargon. En effet, plusieurs pages ayant le même contenu sur un même site pénalisent le référencement de ce site. Malheureusement, on trouve très souvent sur un seule site plusieurs URL permettant d'accéder à la page d'accueil. Comme http://www.lesite.com/, http://lesite.com/ ou encore http://www.lesite.come/index.php etc. Nous allons voir comment régler ce problème.&lt;/p&gt;    &lt;p&gt;Plusieurs solutions sont disponibles pour régler ce problème mais toujours du côté du serveur. Nous allons voir le cas d'apache.&lt;/p&gt;


&lt;p&gt;Il est généralement possible de personnaliser le fonctionnement d'Apache pour un répertoire en particulier en plaçant un fichier .htaccess dans ce répertoire. Il suffira alors d'indiquer dans ce fichier de rediriger le visiteur vers la bonne URL lorsque celle qu'il utilise ne nous satisfait pas.&lt;/p&gt;


&lt;p&gt;Pour cela, il faudra d'abord déterminer l'URL que l'on souhaite utiliser. On choisira www.le-site.com, c'est à dire l'URL contenant le &lt;em&gt;www&lt;/em&gt; car c'est la forme la plus connu et la plus employée.&lt;/p&gt;


&lt;p&gt;Nous allons donc créer un fichier nommé .htaccess. Pour ce faire, il suffit d'ouvrir un éditeur de fichiers texte et d'enregistrer le fichier créé sous ce nom. A noter que sous Windows, il n'est pas possible de créer des fichiers portant ce nom. Vous pourrez le renommer une fois présent sur votre FTP ou exploiter la commande &lt;em&gt;rename&lt;/em&gt; qui autorise ce genre de nom. Placez dans ce fichiers les lignes suivantes&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
# Activation du moteur de réécriture d'URL
RewriteEngine On

# On insère une condition de réécriture
# Si le nom de serveur indiqué ne commence
# pas par www
RewriteCond %{SERVER_NAME} !^www

# Nous allons rediriger le visiteur vers le site avec
# les www
RewriteRule ^(.*)$  http://www.le-site.comg/$1 [R=301,L]&lt;/pre&gt;


&lt;p&gt;Avec ces lignes, n'importe quelle page à laquelle un client accède via un nom de serveur sans les &lt;em&gt;www&lt;/em&gt; sera automatiquement redirigé vers la même page mais avec le bon nom de serveur. D'autre part, vous aurez peut être remarqué que l'erreur 301 est renvoyée au client. Elle signifie &lt;em&gt;Has moved permanently&lt;/em&gt;, et indique aux clients, les moteurs de recherche en particulier, que la page demandée a définitivement été déplacé vers la nouvelle adresse indiquée.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.code-web.org/post/2008/03/09/50-evitez-les-url-multiples-et-le-contenu-duplique#comment-form</comments>
      <wfw:comment>http://www.code-web.org/post/2008/03/09/50-evitez-les-url-multiples-et-le-contenu-duplique#comment-form</wfw:comment>
      <wfw:commentRss>http://www.code-web.org/feed/rss2/comments/35</wfw:commentRss>
    						<h3>Abonnement aux commentaires</h3>
						<p>
							<a href="http://www.code-web.org/subscribetocomments?post_id=35">
								<!-- # If the subscriber is logged in -->
																<!-- # If the subscriber is not logged in -->
																	S'abonner pour recevoir les commentaires suivants par email															</a>
						</p>
					  </item>
    
  <item>
    <title>Les Pseudo Frames</title>
    <link>http://www.code-web.org/post/2007/12/27/15-les-pseudo-frames</link>
    <guid isPermaLink="false">urn:md5:ebe173b4a57ff70396beb2a8d9d5cabd</guid>
    <pubDate>Thu, 27 Dec 2007 20:18:00 +0000</pubDate>
    <dc:creator>Thierry Geindre</dc:creator>
        <category>PHP</category>
        <category>accessibilité</category><category>html</category><category>php</category><category>référencement</category>    
    <description>&lt;p&gt;Vous connaissez peut-être les frames. Il s'agit d'un système fournit par le langage html permettant de découper une page en plusieurs autres pages. Bien que présentant un certain nombres d'avantages, ce système apporte également son lot d'inconvénients qui nous pousserons à utiliser une autre méthode que constituent les pseudo frames.&lt;/p&gt;    &lt;h3&gt;Pourquoi utiliser des frames?&lt;/h3&gt;

&lt;p&gt;Comme je le disais, les frames permettent de mettre en place un découpage d'une page en plusieurs autres. Ceci permet de régler certains problèmes de maintenances d'un site. En effet lorsqu'un menu apparaît sur de nombreuses pages, il peut être fastidieux de le modifier sur chacune de ces pages.&lt;/p&gt;


&lt;p&gt;Grâce aux frames, il est possible de n'avoir ce menu que sur une seule page. Les autres pages du site seront toujours affichées accompagnées de ce menu grâce à un système de cadres.&lt;/p&gt;


&lt;p&gt;Cependant, les frames posent un certain nombre de problèmes.&lt;/p&gt;


&lt;h3&gt;Pourquoi ne pas utiliser les frames?&lt;/h3&gt;

&lt;p&gt;En règle générale, il est bon de développer un site Web en respectant une norme la plus strict et la plus récente possible. Le &lt;a href=&quot;http://www.la-grange.net/w3c/xhtml1/&quot; hreflang=&quot;fr&quot;&gt;XHTML 1.0 Strict&lt;/a&gt; est un bon exemple, et cette norme interdit l'utilisation des frames ou frameset. Ceci n'explique pas pourquoi faut-il se priver des frames mais constitue déjà un premier argument.&lt;/p&gt;


&lt;p&gt;Les frames posent tout une série de problèmes&amp;nbsp;:&lt;/p&gt;

&lt;h4&gt;Des problèmes d'accessibilité&lt;/h4&gt;

&lt;p&gt;Un certain nombre de navigateurs sont incapables d'interpréter les frames. En les utilisant, vous réduisez ainsi le nombre potentiel de visiteurs que votre site pourrait accueillir.&lt;/p&gt;

&lt;h4&gt;De référencement&lt;/h4&gt;

&lt;p&gt;On sait aujourd'hui que les bot des différents moteurs de recherche existant sur le Web ne sont pas vraiment friant des frames. De plus, un visiteur qui cliquera sur un résultat d'une recherche pourra arriver directement sur une page sans avoir les frames affichées. Il perdra ainsi le menu et, là, aucune chance pour qu'il visite d'autre pages de votre site.&lt;/p&gt;


&lt;p&gt;Il existe bien un moyen de régler ce second problème à l'aide de java script, mais on en revient alors à des problèmes d'accessibilité.&lt;/p&gt;


&lt;p&gt;Les frames posent encore d'autre problèmes, une petite recherche vous en donnera certainement la liste complète. Nous avons vu ici les principaux.&lt;/p&gt;


&lt;h3&gt;Les pseudo frames&lt;/h3&gt;

&lt;p&gt;Pour palier aux problèmes des frames, il nous faut une solution qui apporte les mêmes avantages sans les inconvénients bien sur. C'est justement là qu'interviennent les pseudo frames. Il s'agit d'un système qui consiste à construire une page à partir de plusieurs fichiers mais côté serveur uniquement. Ainsi, le mécanisme est totalement invisible pour le client qui ne verra qu'une page correctement construite et sans frame.&lt;/p&gt;


&lt;p&gt;Pour ce faire, nous allons devoir utiliser un langage côté serveur. PHP satisfera parfaitement ce besoin, mais il faut tout de même savoir que n'importe quel autre langage côté serveur pourra faire l'affaire suivant le même principe.&lt;/p&gt;


&lt;h4&gt;Fichiers et arborescence&lt;/h4&gt;

&lt;p&gt;Classiquement, on retrouve pour une page quatre parties biens distinctes&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;L'en-tête (header)&lt;/li&gt;
&lt;li&gt;Le pied de page (footer)&lt;/li&gt;
&lt;li&gt;Le menu&lt;/li&gt;
&lt;li&gt;Le contenu de la page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On aura donc 3 fichiers qui seront systématiquement les mêmes pour toutes les pages d'un site, à savoir&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;header.html (L'en-tête)&lt;/li&gt;
&lt;li&gt;footer.html (Le pied de page)&lt;/li&gt;
&lt;li&gt;menu.html (Le menu)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et un quatrième fichier sera utilisé pour construire une page, il ne s'agira pas du même fichier en fonction de la page que l'on souhaite afficher. Pour structurer un peu l'arborescence de notre site, ou pourra créer deux répertoires. L'un contenant les fichier communs à toute les pages du site et l'autre contenant les différents fichiers qui contiendront les contenus des pages. Ces répertoires pourront être nommés respectivement includes (du verbe To Include (inclure) de l'anglais) et pages.&lt;/p&gt;


&lt;p&gt;En plus de ces répertoires et fichiers, il nous faudra un fichier supplémentaire qui contiendra les instructions de constructions de la page à partir des différents fichiers. Nous utiliserons pour cela un fichier index.php placé à la racine de notre arborescence.&lt;/p&gt;


&lt;p&gt;On obtiendra donc l'arborescence suivante&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;index.php&lt;/li&gt;
&lt;li&gt;includes/
&lt;ul&gt;
&lt;li&gt;header.html&lt;/li&gt;
&lt;li&gt;footer.html&lt;/li&gt;
&lt;li&gt;menu.html&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;pages/
&lt;ul&gt;
&lt;li&gt;accueil.html&lt;/li&gt;
&lt;li&gt;autre.html&lt;/li&gt;
&lt;li&gt;etc.html&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bien entendu, d'autres arborescences pourront être mises en place mais celle-ci satisfera la majorité des cas.&lt;/p&gt;


&lt;h4&gt;Contenu des fichiers&lt;/h4&gt;

&lt;p&gt;Excepté le fichier index.php, tout les autres fichiers devront être remplis avec le code html qui compose les pages de votre site. Cependant, vous ne devrez pas y placer exactement le même contenu que si vous aviez utilisé des frames. En effet, il ne faudra pas placer les en-têtes de pages dans chacun des fichiers mais seulement dans header.html. Un exemple sera certainement plus parlant&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;includes/header.html&lt;/p&gt;
&lt;pre class=&quot;html&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;?xml &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; encoding&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;?&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
﻿&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Strict//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&amp;quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;html&lt;/span&gt; xmlns&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt; xml:&lt;span style=&quot;color: #000066;&quot;&gt;lang&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;lang&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;&lt;/span&gt;Le titre de la page&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/dotclear/themes/CodeWeb/style.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt; 
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Comme nous l'avons déjà vu, notre script index.php vas se charger de construire &lt;strong&gt;une seule page&lt;/strong&gt; à partir des fichiers que nous avons énuméré. Il ne s'agit donc plus de créer plusieurs pages et de les afficher dans des cadres. Ainsi, le code d'en-tête (&amp;lt;head&amp;gt;) ne devra se trouver que dans le fichier header.html et dans aucun autre. De même, le code qui sera destiné à fermer le &amp;lt;body&amp;gt; et &amp;lt;html&amp;gt; ne devra se trouver que dans le fichier footer.html.&lt;/p&gt;


&lt;p&gt;includes/footer.html&lt;/p&gt;
&lt;pre class=&quot;html&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Notre menu pourra être formé d'une simple liste&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;includes/menu.html&lt;/p&gt;
&lt;pre class=&quot;html&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;ul&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;menu&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;index.php&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Accueil&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;index.php?page=autre&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Autre&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il ne nous restera ensuite plus qu'a créer autant de pages que nous le souhaitons dans le répertoire pages. Le minimum serait une page index.html qui sera celle qui sera affichée par défaut. C'est à dire lorsque la page demandée au script index.php ne correspond à aucune page connue ou lorsqu'aucune page n'est demandée. On créera ici une page supplémentaire nommée autre.html pour coller au menu que je vous proposé en exemple.&lt;/p&gt;


&lt;p&gt;pages/index.html&lt;/p&gt;
&lt;pre class=&quot;html&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;&lt;/span&gt;Accueil&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/span&gt;Bienvenue sur l'accueil.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;pages/autre.html&lt;/p&gt;
&lt;pre class=&quot;html&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;&lt;/span&gt;Autre&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;/span&gt;Une autre page.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Construction de la page&lt;/h4&gt;

&lt;p&gt;Comme nous l'avons vu, c'est le script index.php placé à la racine de notre arborescence qui sera chargé de construire une page à partir de tout les fichiers dont il dispose. Ainsi, pour afficher une page on fera toujours appel au fichier index.php avec un paramètre page dans l'URL (méthode GET). On pourra ensuite lire ce paramètre dans notre script via la variable $_GET['page'].&lt;/p&gt;


&lt;p&gt;Par exemple, pour afficher la page autre.html, on utilisera le lien suivant&amp;nbsp;: http://www.site.com/index.php?page=autre Il s'agit du second lien proposé dans le menu d'exemple.&lt;/p&gt;


&lt;p&gt;index.php&lt;/p&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On définit une liste de pages autorisées au moyen d'un tableau&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Vous devrez ajouter toutes les pages se trouvant dans le répertoire&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// pages pour les rendre accessibles.&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Vous pouvez également automatiser la génération de ce tableau&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// en lisant le contenu du répertoire pages/&lt;/span&gt;
  &lt;span style=&quot;color: #ff0000&quot;&gt;$pagesOk&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'index'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'autre'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On commence par lire la page demandée&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Si ce n'est pas vide&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;empty&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'page'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On lit la valeur demandée&lt;/span&gt;
    &lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'page'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;
   &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Sinon on utiliser index comme page par défaut&lt;/span&gt;
   &lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'index'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On vérifie que la page demandée se trouve dans les pages autorisées&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;in_array&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$pagesOk&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Elle n'y est pas, dans ce cas on peut renvoyer une erreur 404&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;HTTP/1.0 404 Not Found&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On stop l'exécution du script ici&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Arrivé ici, on sait que la page demandée existe forcément.&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On va donc pouvoir commencer la construction de la page.&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On commence par inclure l'entête&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/header.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Puis le menu&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/menu.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On inclut la page demandée&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./pages/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On inclut enfin le pied de page&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/footer.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Pour aller plus loin&lt;/h3&gt;


&lt;h4&gt;Protéger vos répertoires contre les accès directes&lt;/h4&gt;

&lt;p&gt;En l'état, un visiteur peut toujours se rendre dans l'arborescence de votre site, et plus particulière dans le répertoire pages ou encore includes. Il pourra donc visualiser n'importe quel page seule. Pour pallier à ce problème, il vous suffira de placer dans chacun des deux répertoires un fichier nommé .htaccess et contenant les instructions suivantes&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;deny from all&lt;/pre&gt;


&lt;p&gt;Vos répertoires seront ainsi totalement inaccessibles publiquement. Ils le resteront bien sur via FTP et pour votre script index.php.&lt;/p&gt;


&lt;h4&gt;Réécriture d'URL&lt;/h4&gt;

&lt;p&gt;Il pourrait être intéressant de simuler l'existence de chacune des pages sur notre site. En effet, ceci facilite généralement la mémorisation des URL et améliore le référencement. Pour ce faire, nous allons exploiter une fonctionnalité offerte par Apache. Il s'agit de la réécriture d'URL, aussi appelée URL Rewriting en anglais. Il faut savoir que cette fonctionnalité est désactivées sur certaines formules d'hébergement, le plus souvent les gratuites. A vous de tester.&lt;/p&gt;


&lt;p&gt;Pour mettre en oeuvre cette fonctionnalité, placez un fichier nommé .htacces à la racine de votre arborescence. Placez-y les instructions suivantes&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;# On active la réécriture d'URL
RewriteEngine on

# On définit une seule règle de réécriture
RewriteRule (.*)\.html index.php?page=$1 [L]&lt;/pre&gt;


&lt;p&gt;Vous pourrez alors utiliser directement l'URL suivante pour afficher la page autre avec l'en-tête, le menu et le pied de page&amp;nbsp;: http://www.site.com/autre.html. Le serveur appellera en fait index.php?page=autre de façon totalement invisible pour le visiteur.&lt;/p&gt;


&lt;h4&gt;Lister automatiquement les pages autorisées&lt;/h4&gt;

&lt;p&gt;Plutôt que de créer une liste figée dans votre script index.php, vous pouvez également générer dynamiquement la liste des pages autorisées en lisant le contenu du répertoire pages. Le script index.php pourra alors contenir les instructions suivantes&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On initialise la liste des pages valides à un tableau vide&lt;/span&gt;
  &lt;span style=&quot;color: #ff0000&quot;&gt;$pagesOk&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On ouvre le répertoire des pages&lt;/span&gt;
  &lt;span style=&quot;color: #ff0000&quot;&gt;$pagesDir&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;opendir&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./pages/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On lit le répertoire&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;readdir&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$pagesDir&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On vérifie qu'il s'agit bien d'un fichier&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// et que son extension est bien .html&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;is_file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;substr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;-4&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
      &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Si c'est bien le cas, on ajoute la page à la liste des pages autorisées&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000&quot;&gt;$pagesOk&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On commence par lire la page demandée&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Si ce n'est pas vide&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;empty&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'page'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On lit la valeur demandée&lt;/span&gt;
    &lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'page'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;
   &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Sinon on utiliser index comme page par défaut&lt;/span&gt;
   &lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'index'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On vérifie que la page demandée se trouve dans les pages autorisées&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// La liste contient désormais l'extension des fichiers, on ajoute donc '.html'&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// a la variable $page à contrôler.&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;in_array&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$pagesOk&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Elle n'y est pas, dans ce cas on peut renvoyer une erreur 404&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;HTTP/1.0 404 Not Found&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On stop l'exécution du script ici&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Arrivé ici, on sait que la page demandée existe forcément.&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On va donc pouvoir commencer la construction de la page.&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On commence par inclure l'entête&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/header.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Puis le menu&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/menu.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On inclut la page demandée&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./pages/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On inclut enfin le pied de page&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'./includes/footer.html'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;A noter que la fonction &lt;a href=&quot;http://fr.php.net/glob&quot; hreflang=&quot;fr&quot;&gt;glob()&lt;/a&gt; pourra également servir à créer la liste des pages autorisées.&lt;/p&gt;


&lt;p&gt;On pourra également mettre en place un système de cache permettant de sauvegarder la liste des pages autorisées plutôt que de chercher à la reconstruire pour chaque appel.&lt;/p&gt;


&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Une fois ce système en place, vous pouvez simplement modifier les fichier d'en-tête (header.html), de menu (menu.html) et de pied de page (footer.html). Ces modifications seront automatiquement répliquées sur l'ensemble des pages qui composent votre site.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.code-web.org/post/2007/12/27/15-les-pseudo-frames#comment-form</comments>
      <wfw:comment>http://www.code-web.org/post/2007/12/27/15-les-pseudo-frames#comment-form</wfw:comment>
      <wfw:commentRss>http://www.code-web.org/feed/rss2/comments/4</wfw:commentRss>
    						<h3>Abonnement aux commentaires</h3>
						<p>
							<a href="http://www.code-web.org/subscribetocomments?post_id=4">
								<!-- # If the subscriber is logged in -->
																<!-- # If the subscriber is not logged in -->
																	S'abonner pour recevoir les commentaires suivants par email															</a>
						</p>
					  </item>
    
  <item>
    <title>Déplacement de pages, utiliser l'erreur 301</title>
    <link>http://www.code-web.org/post/2007/11/13/24-deplacement-de-pages-utiliser-l-erreur-301</link>
    <guid isPermaLink="false">urn:md5:0737bc93ac68df6ca735f4fc372b9fd5</guid>
    <pubDate>Tue, 13 Nov 2007 08:24:00 +0000</pubDate>
    <dc:creator>Thierry Geindre</dc:creator>
        <category>Référencement</category>
        <category>apache</category><category>php</category><category>référencement</category>    
    <description>&lt;p&gt;CodeWeb change d'ici quelques jours de nom de domaine et de serveur. Le site deviendra alors code-web.org. C'est justement l'occasion de faire le point sur les bonnes choses à faire en cas de déplacement de pages. Je pense notamment à l'erreur HTTP 301 et la redirection vers le nouvel emplacement. L'objectif étant bien sur de conserver le référencement acquis et surtout de ne pas créer de liens morts.&lt;/p&gt;    &lt;p&gt;Nous prendrons pour exemple notre cas. Vous verrez donc les quelques éléments que nous avons préparés et que nous allons mettre en place dès que le nouveau nom de domaine sera opérationnel. Mais avant tout, voyons l'objectif à atteindre.&lt;/p&gt;


&lt;h3&gt;Objectif&lt;/h3&gt;

&lt;p&gt;Lorsque vous créez un site sur la toile, il est possible qu'avec le temps des liens externes existent vers vos pages. Les moteurs de recherche constituent l'exemple le plus évident de liens externes. Mais pensons aussi aux liens dans les favoris de vos visiteurs, etc. L'ennui lorsque vous souhaitez déplacer vos pages, c'est que vous n'avez pas le contrôle sur les liens dont nous venons de parler. Notre objectif sera donc de faire en sorte que ces liens fonctionnent toujours.&lt;/p&gt;


&lt;h3&gt;Redirection bien sur!&lt;/h3&gt;

&lt;p&gt;En effet, nous utiliserons une redirection. Ici à l'aide de la fonction &lt;a href=&quot;http://fr.php.net/header&quot; hreflang=&quot;fr&quot;&gt;header&lt;/a&gt; de PHP. Pour vos visiteurs, pas de problème ils pourront être redirigés avec ce seul code&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'location: http://www.nouveau-domain.com/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;En revanche, les moteurs de recherche ne vont certainement pas apprécier et vous risquez de perdre le référencement de vos pages. Pou remédier à cela, il faudra renvoyer une erreur 301 du protocole HTTP. Ce code correspond à l'erreur &quot;Moved Permanently&quot;, comprenez &quot;Déplacé définitivement&quot;. La redirection qui suivra cette erreur prendra donc tout son sens pour un moteur de recherche qui pourra ainsi mettre à jour son index.&lt;/p&gt;


&lt;h3&gt;L'exemple&lt;/h3&gt;

&lt;p&gt;Prenons donc CodeWeb comme exemple. Remarquez que les adresses de nos pages sont actuellement construites ainsi&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;http://codeweb.free.fr/dotclear/index.php/2007/11/12/24-deplacement-de-pages-utiliser-l-erreur-301&lt;/pre&gt;


&lt;p&gt;Sur notre nouveau nom de domaine elles seront formées ainsi&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;http://www.code-web.org/index.php/2007/11/12/24-deplacement-de-pages-utiliser-l-erreur-301&lt;/pre&gt;


&lt;p&gt;On peut donc constater qu'elle possède une partie commune. C'est la partie de l'URL qui est totalement indépendant du nom de domaine. C'est celle-ci que nous allons récupérer pour effectuer la redirection vers la bonne page. Nous remplacerons donc le fichiers index.php actuellement en place dans le répertoire /dotclear/ par le script suivant&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On créé la nouvelle URL à partir de l'ancienne que l'on vient de récupérer&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// via $_SERVER['REQUEST_URI']&lt;/span&gt;
	&lt;span style=&quot;color: #ff0000&quot;&gt;$link&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'http://www.code-web.org/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;str_replace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'/dotclear/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$_SERVER&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'REQUEST_URI'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// L'erreur 301&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;HTTP/1.1 301 Moved Permanently&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// La redirection&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'location: '&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$link&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// On indique qu'il n'y a plus rien à voir ici&lt;/span&gt;
	&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Connection: close&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ainsi, lorsqu'un visiteur tentera de se rendre sur http://codeweb.free.fr/dotclear/index.php il sera automatiquement redirigé ver http://www.code-web.org/index.php. De même pour les moteurs de recherche qui pourront, en plus, mettre a jour leur index avec les nouvelles adresses.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.code-web.org/post/2007/11/13/24-deplacement-de-pages-utiliser-l-erreur-301#comment-form</comments>
      <wfw:comment>http://www.code-web.org/post/2007/11/13/24-deplacement-de-pages-utiliser-l-erreur-301#comment-form</wfw:comment>
      <wfw:commentRss>http://www.code-web.org/feed/rss2/comments/9</wfw:commentRss>
    						<h3>Abonnement aux commentaires</h3>
						<p>
							<a href="http://www.code-web.org/subscribetocomments?post_id=9">
								<!-- # If the subscriber is logged in -->
																<!-- # If the subscriber is not logged in -->
																	S'abonner pour recevoir les commentaires suivants par email															</a>
						</p>
					  </item>
    
</channel>
</rss>