[英]I can't remove the index.php from the CodeIgniter URL
我想从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 ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index\.php|assets/|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
但它们都没有奏效。
我还试图将uri_protocol更改为:
$config['uri_protocol'] = 'ORIG_PATH_INFO';
但它仍然无效。
我怎么解决这个问题 ?
我尝试使用此代码来检查mod_rewrite是否已启用:
<?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_rewrite不可用
我有同样的问题..然后最终它使用以下代码
只需按照以下简单步骤:
1.将以下代码保存到.htaccss文件中..
2.把它放在主项目文件夹(不是应用程序文件夹)中
3.将代码第3行的“/ projectFolderName /”部分重命名为项目文件夹名称。
<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>
这适合我。 Inyour .htaccess文件写道:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
并在您的config.php文件中:
$config['uri_protocol'] = 'AUTO';
确保你的根文件夹中的htaccess不在应用程序文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.