【发布时间】:2023-03-25 07:20:01
【问题描述】:
我想从 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 不可用
【问题讨论】:
-
尝试将url协议设置为自动
$config['uri_protocol'] = 'AUTO'; -
您的 htaccess 看起来不错。您确定您的网络服务器支持 htaccess 并启用了 mod_rewrite 吗?
-
@jonijones 我已经这样做了,但同样的问题:/
-
@FabrícioMatté 请检查我对帖子所做的修改
-
看看有没有帮助askubuntu.com/q/48362/107606
标签: php .htaccess codeigniter indexing