Archives pour l'étiquette RewriteRule

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

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.