删除本地代码点火器的索引.php


Removing index.php of codeigniter on local

我正在尝试在我的本地主机中删除索引.php,但它似乎不起作用,它http://localhost/testing.

我把.htacces放在htdocs下的"测试"目录中。

LoadModule rewrite_module modules/mod_rewrite.so 在 Apache/conf 也已经取消检查。

这是我的.htaccess:

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

这是我的配置:

$config['base_url']    = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

当我访问登录控制器时,找不到它。

未找到

在此服务器上找不到请求的 URL/testing/login。

我真的不知道接下来该尝试什么。任何帮助将不胜感激。

试试这个:-

配置.php :-

$config['base_url'] = 'http://localhost/testing/';
$config['index_page'] = '';

.htaccess

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

你的htaccess应该是这样的

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

没有必要附加/testing/,因为RewriteBase已经处理好了。

基本上是索引.php包含在所有URL中:

我们可以使用简单的规则使用 .htaccess 将其删除。 以下是此类文件的示例,使用"否定"方法,其中所有内容都被重定向,

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

现在重新启动服务器并检查

省略RewriteBase中的尾部斜杠:

RewriteEngine On
RewriteBase /testing
RewriteCond $1 !^(index'.php|robots'.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

$config['base_url']应该http://localhost/testing/

$config['index_page']应为空。

在 .htaccess 文件中试试这个:

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

你的配置文件很好

区别在于索引后的"?.php

您可能还想尝试更改 ./application/config/config.php 中 $config[‘uri_protocol’] 的值。有时CodeIgniter会出错。将其更改为PATH_INFO可能会起作用。