您的位置:首页 > 编程语言 > PHP开发

Codeigniter - 去除URL中的index.php

2013-03-29 10:43 387 查看
在Codeigniter中默认url的形式:http://huangjacky.com/index.php/controller/action/param1/param2,那么如何去掉这个url中的index.php呢?其实我们只需要在根目录创建一个.htaccess文件,定义一下规则即可,.htaccess文件的具体内容如下:

# Customized error messages.


[code]ErrorDocument 404 /index.php


 


# Set the default handler.


DirectoryIndex index.php


 


# Various rewrite rules.


<IfModule mod_rewrite.c>


RewriteEngine on


RewriteCond %{REQUEST_FILENAME} !-f


RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^(.*)$ index.php?/$1 [L,QSA]


</IfModule>

[/code]

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

在nginx下还需要再修改一下这个重定向。等我再研究。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: