J’ai supprimer le index.php de l’url sur ce blog Dotclear 2 avec les rewrites rules d’apache

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

Simplement en suivant les conseils de Jean-Christophe Duvivier

J’ai configuré mon blog DC2 comme ceci

  • Panneau d’administration > Paramètres du Blog :
  • URL du Blog : L’url complète de votre blog (en ce qui me concerne : http://www.karlesnine.com/)
  • Méthode de lecture de l’url : Sélectionnez PATH_INFO
  • Enregistrez

J’ai évité d’utiliser le .htaccess et j’ai directement porté mes RewriteRule dans la vhost de mon apache 2 comme ceci :

&lt;VirtualHost *:<span style="color: #ff0000;">80</span>&gt; 	 <span style="color: #00007f;">ServerName</span> www.karlesnine.com 	 <span style="color: #00007f;">ServerAlias</span> karlesnine.com 	 <span style="color: #00007f;">DocumentRoot</span> /var/www/karlesnine.com 	 <span style="color: #00007f;">ErrorLog</span> /var/log/apache/error.log 	 <span style="color: #00007f;">CustomLog</span> /var/log/apache/access.log combined &nbsp; 	<span style="color: #adadad; font-style: italic;"># DirectoryIndex index.php</span> &nbsp; 	<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span> 	<span style="color: #00007f;">RewriteLog</span> <span style="color: #7f007f;">&quot;/var/log/apache/rewrite.log&quot;</span>         <span style="color: #00007f;">RewriteLogLevel</span> <span style="color: #ff0000;">0</span> &nbsp; 	<span style="color: #adadad; font-style: italic;"># Special spam commentaire .ru .china .jp</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">81</span>\.<span style="color: #ff0000;">177</span>\.<span style="color: #ff0000;">14</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>        <span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">81</span>\.<span style="color: #ff0000;">177</span>\.<span style="color: #ff0000;">15</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>        <span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">121</span>\.<span style="color: #ff0000;">14</span>\.<span style="color: #ff0000;">75</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">210</span>\.<span style="color: #ff0000;">159</span>\.<span style="color: #ff0000;">140</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">210</span>\.<span style="color: #ff0000;">136</span>\.<span style="color: #ff0000;">18</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">157</span>\.<span style="color: #ff0000;">220</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">156</span>\.<span style="color: #ff0000;">227</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">222</span>\.<span style="color: #ff0000;">229</span>.\<span style="color: #ff0000;">216</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">203</span>\.<span style="color: #ff0000;">141</span>\.<span style="color: #ff0000;">129</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">157</span>\.<span style="color: #ff0000;">220</span>\. 	<span style="color: #00007f;">RewriteRule</span> .* -                                        <span style="color: #66cc66;">&#91;</span>F,L<span style="color: #66cc66;">&#93;</span> &nbsp; &nbsp; 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^<span style="color: #66cc66;">&#40;</span>/admin/|/cache/|/db/|/images/|/inc/|locales/|/plugins/<span style="color: #66cc66;">&#41;</span> 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^<span style="color: #66cc66;">&#40;</span>/favicon.ico/|/icons/|/local/|/dotclear/|/themes/|/public/<span style="color: #66cc66;">&#41;</span> 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^/index.php 	<span style="color: #00007f;">RewriteRule</span> <span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$ /index.php/$<span style="color: #ff0000;">1</span> &nbsp; &lt;/VirtualHost&gt;

J’ai découpe la ligne de RewriteCond en deux pour une question de lecture. J’ai ajouter quelque condition entre autre sur favicon.ico qui malgré le plugin myfavicon n’apparaissait pas.

9 réflexions sur « J’ai supprimer le index.php de l’url sur ce blog Dotclear 2 avec les rewrites rules d’apache »

  1. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    Houla ! c’est une solution bien compliquée !
    En voici une plus simple qui fonctionne bien également
    http://blog.jaycreation.net/post/En

  2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    Dit jaycreation je suis pas contre l’auto promo mais venir me dire ma solution est compliqué alors que tu propose strictement la même a base de RewriteRule sur ton post. Les seul différence est l’utilisation .htaccess mais tu dois pas comprendre pourquoi je l’utilise pas et le PATH_INFO vs QUERY_STRING mais la aussi tu dois pas vraiment comprendre la différence.

    Bref au choix tu me prendre pour une truffe, ou t’es un cave, note que les deux simultané c’est aussi possible.

    Suis pas d’humeur

  3. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    La solution de Karlesnine est efficace dans la mesure ou il gère des exceptions
    Ça évite que tout requête passe par la case « t’es un fichier ou un répertoire » ?
    Ce qui a force est lourd pour le système (comprendre apache, php et l’os)
    Et je parlerais pas de l’utilisation du .htaccess qui est un tue-serveur ^^

    Par contre moi j’aurais poussé le vice a faire ceci :

    RewriteRule .* /index.php/%{REQUEST_URI}

    Ca évite de stocker une variable qui existe déjà
    (note que tu peux rajouter %{QUERY_STRING} juste derriere si tu veux les conserver, mais j’en doute 🙂

  4. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    Merci Kathryl, le pb du fichier .htaccess c’est les I/O pour chaque hit, bon ok le système à un cache mais bon c’est mal. Quand en plus tu ajoute un test sur la nature de l’élément appelé c’est du suicide avec la moindre audience conséquente.

  5. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    @Kathryl %{QUERY_STRING} dans un rewrite rule, c’est mal ! Les flags sont là pour ça. En l’occurence, il suffit d’utiliser le flag QSA :p

  6. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    Bon et bien je vais finir par le remercier le perdreau, j’apprend des truc avec les réactions 🙂

  7. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    @karles comme quoi, le backlink bourrin et trollesque a du bon parfois 😉

  8. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    @JB anéfé ! j’oublie toujours ce flag 🙂
    Mais la variable existe dans tout les cas 😉

  9. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/www/karlesnine.com/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68

    vi, elle existe, mais c’est plus propre de ne l’utiliser que dans les RewriteCond 😉

Laisser un commentaire