codeiginter -- 路由配置 routes.php

路由配置的话 直接找手册就可以了

http://codeigniter.org.cn/user_guide/general/routing.html


但是想把index.php 去掉 

那要启用apache 的 rewrite 模块

在 http.conf 中


#LoadModule rewrite_module modules/mod_rewrite.so

改为:LoadModule rewrite_module modules/mod_rewrite.so



 #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

 改为

AllowOverride All


----------------------------------

写.htaccess 并且放入与index.php 同级目录下

.htaccess 内容如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php
#controller, previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /codeigniter/index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends
#the request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /codeigniter/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>


再找到 application/config.php 文件下的
$config['index_page'] = 'index.php';
改为
$config['index_page'] = '';




你可能感兴趣的:(codeiginter -- 路由配置 routes.php)