0

我正在尝试删除我的本地主机中的 index.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。

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

4

6 回答 6

1

尝试这个 :-

配置.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]
于 2013-10-19T10:23:29.743 回答
0

省略后面的斜杠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']应该是空白的。

于 2013-10-19T14:27:30.707 回答
0

在 .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

你的配置文件没问题

区别在于“?” 在 index.php 之后

于 2013-10-19T14:54:03.327 回答
0

htaccess应该像

RewriteEngine On
RewriteBase /testing/

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

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

于 2013-10-19T10:04:46.413 回答
0

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

于 2013-10-19T15:21:33.797 回答
0

基本上 index.php 包含在所有 URL 中:

我们可以通过简单的规则使用 .htaccess 删除它。以下是此类文件的示例,使用重定向所有内容的“否定”方法,

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

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

于 2013-10-19T09:52:10.713 回答