CodeIgniter从url中删除index.php

CodeIgniter从url中删除index.php,php,apache,.htaccess,codeigniter,configuration,Php,Apache,.htaccess,Codeigniter,Configuration,从CI应用程序URL中删除index.php时遇到问题。遵循官方文件,但显然还缺少一些东西。 我设置了一个CI应用程序,并将其放在服务器上的/var/www/test上,其中test是指向/home/user/websites/test的符号链接。 如果我做http://myIp/test/index.php/welcome,但如果我这样做了,我会工作http://myIp/test/welcome。 我在测试文件夹中包含了一个.htaccess,其中包含以下内容: RewriteEngine

从CI应用程序URL中删除index.php时遇到问题。遵循官方文件,但显然还缺少一些东西。 我设置了一个CI应用程序,并将其放在服务器上的/var/www/test上,其中test是指向/home/user/websites/test的符号链接。 如果我做
http://myIp/test/index.php/welcome
,但如果我这样做了,我会工作
http://myIp/test/welcome
。 我在测试文件夹中包含了一个.htaccess,其中包含以下内容:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
而且还玩了RewriteBase属性,但没有成功。
我做错了什么或错过了什么

打开
应用程序/config/config.php
,然后更改

$config['index_page'] = 'index.php'; 

试试这个:

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

您的重写规则不正确(或者最多有错误)。应该是这样的

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

RewriteRule
中的
[L]
标志向apache指示,不应处理进一步的规则,并且应立即应用该规则。有关这方面的更多信息,请参阅。在您的情况下,这很重要,因为您使用的是符号链接和
.htaccess
文件,而不是将规则直接应用于vhost文件,在这种情况下,以及.htaccess速度较慢的情况下,强烈建议使用此选项。

如果我正确回答了您的问题,您希望使您的链接正常工作并从URL中删除'index.php'。请按照以下步骤操作,并让我知道这是否解决了您的问题

1) 从config目录中的config.php中删除'index.php',使其看起来像
$config['index\u page']=''

2) 将此添加到.htaccess文件

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
如果您有任何疑问或问题,请告诉我。希望能有所帮助


向您致意,泽山。

请将以下内容放入.htaccess

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

<Files "index.php">
AcceptPathInfo On
</Files>
重新编写引擎打开
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
上的AcceptPathInfo
将此文件放在index.php附近,从应用程序和系统文件夹中取出,并放在它们附近
别忘了写$config['index_page']='';而不是$config['index_page']='index.php'

抱歉,忘了提一下我也做了,但没有成功。请尝试删除前导斜杠:RewriteRule^(.*)$index.php/$1[L]它也不起作用。。。我做错什么了吗?我通过一个符号链接将CI测试应用程序放在默认的Apache web文件夹(/var/www)上,没有进一步的配置。我正在测试应用程序根目录中编辑.htaccess。这里有什么问题吗?这可能与权限有关吗?您是否已在服务器上运行mod_rewrite
phpinfo()
将告诉您是否启用它您可以检查以下url。。。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

<Files "index.php">
AcceptPathInfo On
</Files>