歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> APACHE重寫去除入口文件index.php,

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

日期:2017/3/3 18:09:28   编辑:學習Linux

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

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>




參考鏈接:http://www.cnblogs.com/tianguook/p/3726457.html

http://xxxxxx/Linuxjc/1169736.html TechArticle

Copyright © Linux教程網 All Rights Reserved