从CodeIgniter URL中删除index.php

从CodeIgniter URL中删除index.php,php,apache,.htaccess,codeigniter,mod-rewrite,Php,Apache,.htaccess,Codeigniter,Mod Rewrite,我正在努力删除CodeIgniter URL中的'index.php'部分。 我使用的是CodeIgniter版本3.1.2。我已经按照所有步骤回答了有关此问题的其他问题: 将$config['index\u page']='index.php'更改为$config['index\u page']='' 将$config['uri\u protocol']='AUTO'更改为$config['uri\u protocol']='REQUEST\u uri' 在我的项目的根文件夹中添加了一个.h

我正在努力删除CodeIgniter URL中的'index.php'部分。 我使用的是CodeIgniter版本3.1.2。我已经按照所有步骤回答了有关此问题的其他问题:

  • $config['index\u page']='index.php'
    更改为
    $config['index\u page']=''
  • $config['uri\u protocol']='AUTO'
    更改为
    $config['uri\u protocol']='REQUEST\u uri'
  • 在我的项目的根文件夹中添加了一个.htaccess文件,代码如下:
重新编写引擎打开
1美元^(索引\.php | resources | robots\.txt)
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]

但是,当我尝试访问我的站点时,我得到以下错误代码

找不到

在此服务器上找不到请求的URL/Toneel/Site/index

重写模块在我的Apache服务器中打开。
有人能帮我解决这个问题吗?

在.htaacess中尝试以下代码:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]

这个环境适合我

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

然后重新启动服务器。

在.htaccess文件中尝试此操作

RewriteEngine On
RewriteBase /yourfolderhere/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

就我而言,它适用于:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /project-name

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [QSA,L]
</IfModule>

在本地主机上运行RewriteEngine时,在RewriteEngine打开后添加RewriteBase/您的\u项目\u名称,并在将代码上载到服务器时仅添加RewriteBase/即可。感谢您的回答,但此代码会给出相同的错误结果。我已经尝试了所有可能的.htaccess代码,但在“重写”模块打开后,这些代码都不起作用。您是否重新启动了服务器@Yaniicki认为AllowOverride是问题所在。我将其更改为“全部”,错误从“未找到”更改为:禁止您无权访问此服务器上的/Toneel/Site/index。我的Apache错误日志显示以下内容:
选项FollowSymLinks和symlinksFownerMatch都已关闭,因此,RewriteRule指令也被禁止,因为它具有绕过目录限制的类似功能
您使用的是哪个操作系统?Windows 10 Professional
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /project-name

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [QSA,L]
</IfModule>
$config['base_url'] = 'http://your-url-here/';
$config['index_page'] = '';