【问题标题】:codeigniter, 404 not found errorcodeigniter,404未找到错误
【发布时间】:2015-09-19 12:33:52
【问题描述】:

我有一个网站,我已经在子文件夹 (test) 下安装了 CodeIgniter 2 Site

用户可以通过以下链接访问该网站:

http://www.example.com/test/

当用户使用上述链接 URL 访问 (test) 站点时,重定向到以下链接并显示以下错误。

http://www.example.com/test/login

找不到

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

然后我将index.php添加到上面的URL,显示登录页面。

http://www.example.com/test/index.php/login

当我再次提交我的用户名和密码时,URL 重定向到,没有登录。

http://www.example.com/test/login

又一次,没有找到。

.htaccess:

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

config.php:

$config['base_url'] =  '';
$config['index_page'] = '';
$config['uri_protocol'] = "AUTO" ;

我已尝试$config['base_url'] = "http://www.example.com/test" - 仍然无法正常工作。

【问题讨论】:

  • 你加载了 url helper 吗?在 autoload.php $autoload['helper'] = array('url');
  • 删除//$config['base_url'] = 'http://www.example.com/test'之间的空格
  • 检查所有控制器和模型文件名和类名的首字母大写
  • 此站点在本地主机中工作,但在线无法正常工作
  • 测试这个$config['uri_protocol'] = 'PATH_INFO';$config['uri_protocol'] = 'REQUEST_URI';

标签: php .htaccess codeigniter


【解决方案1】:

config/config.php

$config['base_url'] = 'https://stackoverflow.com/';
$config['index_page'] = '';

在 .htaccess 中(放置在应用程序文件夹之外)

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

【讨论】:

  • 什么都没有发生......我的代码在我的本地主机上正常工作。但不在网络服务器中。
  • 现场网址来看看这个??
  • 直播网址; noritake.lk/themes 请检查,带有 index.php noritake.lk/themes/index.php/login ,无法登录,重定向到 noritake.lk/themes/login
  • 你把htaccess 放在文件夹外面了吗??
  • noritake.lk/themes 文件夹中的 htaccess
【解决方案2】:

在你的 .htaccess 中试试这个

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

【讨论】:

    【解决方案3】:

    用此代码替换 .htaccess

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

    【讨论】:

      猜你喜欢
      • 2015-03-30
      • 1970-01-01
      • 2022-08-21
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 2016-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多