Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何删除CodeIgniter中的index.php?_Codeigniter_Clean Url - Fatal编程技术网

如何删除CodeIgniter中的index.php?

如何删除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

我有个问题。我需要从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",
        "^/([^.]+)$" => "/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']=''空白。

我希望你能理解……但这不是一个问题。。。在这里看到更多