我有代码.htacces在您使用Codeigniter时很熟悉
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
但它没有用。像这样。
当我删除这个.htacces时,代码运行良好。我已经检查了apache上的mod_rewrite是否启用。我很困惑,请帮忙
答案 0 :(得分:1)
尝试这个
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /projectname
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
注意:projectname是您的根文件夹名称
答案 1 :(得分:1)
即使您启用了mod_rewrite,仍然有一个设置可以阻止.htaccess工作。
检查您的 httpd.conf 文件,并确保在目录设置中
AllowOverride None
更改为
AllowOverride All
如果您需要更多详细信息,请询问!我已经非常简短了。
答案 2 :(得分:1)
在.htaccess
中试试RewriteEngine on
RewriteBase /ci
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
并在application / config / config.php
中$config['index_page'] = ''; // make it empty.