如何删除CodeIgniter中的index.php?
我有个问题。我需要从CodeIgniter框架的URL中删除index.php。有人能帮我吗?对于lighttpd: 启用mod_rewrite模块并在lighttpd.conf中进行设置如何删除CodeIgniter中的index.php?,codeigniter,clean-url,Codeigniter,Clean Url,我有个问题。我需要从CodeIgniter框架的URL中删除index.php。有人能帮我吗?对于lighttpd: 启用mod_rewrite模块并在lighttpd.conf中进行设置 server.document-root = "/var/www/ci/", url.rewrite-once = ( "/(.*)\.(.*)" => "$0", "/(css|files|img|js|stats|user_guide)/" => "$0
server.document-root = "/var/www/ci/",
url.rewrite-once = (
"/(.*)\.(.*)" => "$0",
"/(css|files|img|js|stats|user_guide)/" => "$0",
"^/([^.]+)$" => "/index.php/$1"
)
要避免codeigniter url中出现“index.php”,请执行以下步骤
1.从system/application/config目录打开config.php并替换
$config['index_page'] = “index.php”
by
$config['index_page'] = “”;
2.在CodeIgniter目录(系统目录所在)的根目录中创建一个“.htaccess”文件,使用您喜爱的文本编辑器打开该文件,写下以下脚本并保存:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
3.在某些情况下,uri_协议的默认设置无法正常工作。要解决这个问题,只需更换
$config['uri_protocol'] = “AUTO”
by
$config['uri_protocol'] = “REQUEST_URI”
在system/application/config/config.php中,您只需在项目文件夹中创建.htaccess文件并写入:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#And You don't need to define in base_url in config file:
$config['base_url'] = '';// blank it.
重新编写引擎打开
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则^(.*)$index.php?url=$1[PT,L]
ErrorDocument 404 index.php
#您不需要在配置文件的base_url中定义:
$config['base_url']=''空白。
我希望你能理解……但这不是一个问题。。。在这里看到更多