删除索引.php在代码点火器 -htaccess 中


Removing index.php in codeigniter -htaccess

我在过去 4 天内试图从 url 中删除索引.php但没有成功。

http://domainName.com/CI/index.php/controller-name/function/parameter

CI是托管在goaddy中的文件夹。

/
.htaccess

谷歌搜索后,我尝试使用以下代码,但只得到一个空白页或错误:500,而且我不明白逻辑。请有人帮我找到我出错的地方。

RewriteEngine on
RewriteCond $1 !^(index'.php|[Javascript / CSS / Image root Folder name(s)]|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

第二

RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L] 

我还更改了行,CI/应用程序/配置/配置.php

$config['index_page'] = '';

$config['uri_protocol'] = "REQUEST_URI"

这应该有效

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ CI/index.php/$1 [L]

试试这个它的工作意味着回复我

RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

按照以下步骤操作:

  1. 像这样更改配置文件:

    $config['index_page'] = '';

    $config['uri_protocol'] = '自动';

  2. 使用以下 .htaccess:

RewriteEngine on RewriteCond $1 !^(index'.php|resources|robots'.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]

注意:.htaccess 因服务器而异。某些服务器(例如:Godaddy)需要使用以下.htaccess:

RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

看这里

在base_url中使用以下代码:

$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');