我能';t从CodeIgniter URL中删除index.php
我想从CodeIgniter中的路径中删除index.php 我试图更改配置文件中index_page的值,如下所示:我能';t从CodeIgniter URL中删除index.php,php,.htaccess,codeigniter,indexing,Php,.htaccess,Codeigniter,Indexing,我想从CodeIgniter中的路径中删除index.php 我试图更改配置文件中index_page的值,如下所示: $config['index_page'] = ''; 然后我尝试了所有这些。htaccess: RewriteEngine on RewriteBase / # Hide the application and system directories by redirecting the request to index.php RewriteRule ^(applicati
$config['index_page'] = '';
然后我尝试了所有这些。htaccess:
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
但它仍然不起作用 我怎样才能解决这个问题 编辑: 我尝试了以下代码来检查mod_重写是否已启用:
<?php
if( ! function_exists('apache_get_modules') ){ phpinfo(); die; }
$result = ' not available';
if(in_array('mod_rewrite',apache_get_modules())) $result = 'available';
?>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $result"; ?></p>
我得到了这个结果:
Apache/2.2.22(Ubuntu)
mod_重写不可用
这对我有用。在.htaccess文件中写入:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
在config.php文件中:
$config['uri_protocol'] = 'AUTO';
确保yout htaccess位于根文件夹中,而不是应用程序文件夹中。我也遇到了同样的问题。。最后,它使用了以下代码 只需遵循以下简单步骤:
1.将以下代码保存到.htaccess文件中
2.将其放入主项目文件夹(而不是应用程序文件夹)
3.将代码第3行的“/projectFolderName/”部分重命名为 您的项目文件夹名称。
那你就完了。刷新并查看。
重新启动发动机
重写基本/项目文件夹名称/
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
尝试将url协议设置为自动$config['uri_protocol']='auto'代码>您的htaccess看起来很好。你确定你的web服务器支持htaccess并启用了mod_rewrite吗?@jonijones我已经这样做了,但同样的问题:/@Fabriciomatté请检查我对帖子所做的修改,看看是否有帮助
$config['uri_protocol'] = 'ORIG_PATH_INFO';
<?php
if( ! function_exists('apache_get_modules') ){ phpinfo(); die; }
$result = ' not available';
if(in_array('mod_rewrite',apache_get_modules())) $result = 'available';
?>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $result"; ?></p>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
$config['uri_protocol'] = 'AUTO';
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectFolderName/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>