APACHE重寫去除入口文件index.php


下面我說下 apache 下 ,如何 去掉URL 里面的 index.php 
例如: 你原來的路徑是: localhost/index.php/index 
改變后的路徑是: localhost/index 

1.httpd.conf配置文件中加載了mod_rewrite.so模塊 //在APACHE里面去配置 
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警號去掉 

2.在APACHE里面去配置 ,將里面的AllowOverride None都改為AllowOverride All

注意:修改之后一定要重啟apache服務。 

3.確保URL_MODEL設置為2, (url重寫模式)

在項目的配置文件里寫 

return Array( 
‘URL_MODEL’ => ’2′, 
); 
4 新建文件名為 .htaccess 的文件,放於根目錄下,內容如下: 

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>




 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM