{"id":127,"date":"2012-02-15T14:26:09","date_gmt":"2012-02-15T12:26:09","guid":{"rendered":"http:\/\/blog.bellanca-web.com\/?p=127"},"modified":"2016-04-18T09:21:24","modified_gmt":"2016-04-18T08:21:24","slug":"cacher-le-index-php-dans-lurl","status":"publish","type":"post","link":"https:\/\/blog.bellanca-web.com\/?p=127","title":{"rendered":"Cacher le \u00ab\u00a0index.php\u00a0\u00bb dans l&rsquo;URL"},"content":{"rendered":"<p>Par d\u00e9faut, les URLs d&rsquo;une application sur Yii Framework affichent \u00ab\u00a0index.php\u00a0\u00bb. Voici comment le cacher.<\/p>\n<p>Pour commencer, il faut que le mod_rewrite de PHP soit actif. Pour l&rsquo;activer, il faut ouvrir le fichier httpd.conf et changer la ligne<\/p>\n<pre class=\"lang:default decode:true \">#LoadModule rewrite_module modules\/mod_rewrite.so<\/pre>\n<p>en<\/p>\n<pre class=\"lang:default decode:true\">LoadModule rewrite_module modules\/mod_rewrite.so<\/pre>\n<p>Ensuite, il faut cr\u00e9er un fichier .htaccess au m\u00eame niveu que le fichier index.php.<br \/>\nIl faut y mettre :<\/p>\n<pre class=\"lang:default decode:true \">RewriteEngine On\r\nRewriteBase \/\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule ^(.*)\\?*$ index.php\/$1 [L,QSA]<\/pre>\n<p>Si cela ne fonctionne pas, essayer avec :<\/p>\n<pre class=\"lang:default decode:true \">RewriteEngine on\r\n\r\n# if a directory or a file exists, use it directly\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\n\r\n# otherwise forward it to index.php\r\nRewriteRule . index.php<\/pre>\n<p>Finalement, il faut ajouter la ligne \u00ab\u00a0&lsquo;showScriptName&rsquo;=&gt;false,\u00a0\u00bb dans le fichier de configuration main.php comme suite :<\/p>\n<pre class=\"lang:default decode:true \">'urlManager'=&gt;array(\r\n'urlFormat'=&gt;'path',\r\n'showScriptName'=&gt;false,\r\n\/\/'caseSensitive'=&gt;false,\r\n),<\/pre>\n<p>Normalement, le tour est jou\u00e9!<br \/>\nEnjoy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Par d\u00e9faut, les URLs d&rsquo;une application sur Yii Framework affichent \u00ab\u00a0index.php\u00a0\u00bb. Voici comment le cacher. Pour commencer, il faut que le mod_rewrite de PHP soit actif. Pour l&rsquo;activer, il faut ouvrir le fichier httpd.conf et changer la ligne #LoadModule rewrite_module modules\/mod_rewrite.so en LoadModule rewrite_module modules\/mod_rewrite.so Ensuite, il faut cr\u00e9er un fichier .htaccess au m\u00eame niveu &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.bellanca-web.com\/?p=127\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;Cacher le \u00ab\u00a0index.php\u00a0\u00bb dans l&rsquo;URL&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,22],"tags":[],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-php","category-yii-framework"],"_links":{"self":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":3,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"predecessor-version":[{"id":219,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions\/219"}],"wp:attachment":[{"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bellanca-web.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}