以下代码位于我的.httaccess文件中。
#write your project folder name as rewritebase
RewriteBase /Codeignitor3D/
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]
它给出了500内部服务器错误
答案 0 :(得分:2)
试试这条规则:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
在config.php
文件中,
//Find
$config['index_page'] = "index.php"
//and replace it with
$config['index_page'] = ""
答案 1 :(得分:1)
从url codeigniter中删除index.php的步骤:
配置更改:转到“application / config / config.php”
查找以下代码:
$config['index_page'] = 'index.php';
替换为以下代码:
$config['index_page'] = '';
.htaccess更改:如果您没有任何htaccess,请创建new并将其放在您的根目录上。
注意:如果你在子目录中有codeigniter,则将RewriteBase改为RewriteBase / subdir /
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
现在打开您的网站页面,您将找到没有index.php的干净网址。所以你的所有网址都是http://example.com/controller/method。现在,对index.php的任何HTTP请求都将被视为对index.php文件的请求。
如果仍有问题:需要再应用一次配置更改。 转到“application / config / config.php” 查找以下代码
$config['uri_protocol'] = 'AUTO';
替换为以下代码
$config['uri_protocol'] = 'REQUEST_URI';
现在您已完全从url codeigniter中删除index.php并在codeigniter中获取干净的URL。
答案 2 :(得分:0)