找不到对象! codeigniter 项目中的错误 404
Object not found! Error 404 in codeigniter project
我看到其他用户提出了类似的问题,但 none 对我有用。我有一个 CodeIgniter 项目,它在我的本地主机上运行得很好。我创建了虚拟主机,以便我可以托管许多项目。我确实获得了网站的第一页(登录页面),但是当登录系统时,我得到了如下所示的错误,而不是下一个有效页面。
Object not found! The requested URL was not found on this server. The
link on the referring page seems to be wrong or outdated. Please
inform the author of that page about the error. If you think this is a
server error, please contact the webmaster. Error 404
127.0.0.1 Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3
这是来自www/site/log.../
的错误日志
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57053] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57053] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57058] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57058] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
和我的 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /accounting/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
我的虚拟主机设置:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/www/saseco"
ServerName saseco.dev
ServerAlias www.saseco.dev
CustomLog "C:/www/saseco/logs/saseco.local.access.log" combined
ErrorLog "C:/www/saseco/logs/saseco.local.error.log"
<Directory "C:/www/saseco">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
我的登录控制器的部分片段:
function user_login()
{
if(isset($_POST['enter'])) //Login button pressed
{
$data = $_POST;
$check = $this->login_model->login_match($data);
谁能告诉我哪里做错了?
好的,所以在代码中您没有向我们展示 - 您需要在创建 http://127.0.0.1/saseco/login/user_login
的位置更改它并使其生成 http://www.saseco.dev/login/user_login
因为根据您的虚拟主机,这是两个截然不同的位置设置。
所以你需要有类似 <?php echo base_url('login/user_login');?>
的东西
并确保在 /application/config/config.php 中正确配置了 $config['base_url']。
尝试
$config['base_url'] = '';
或硬编码为
$config['base_url'] = 'http://www.saseco.dev/';
补充:
不确定为什么将 RewriteBase 设置为会计,因此请尝试更改
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /accounting/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
至
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
<?
?>
试试这个:
<?php
?>
对我有用。
我看到其他用户提出了类似的问题,但 none 对我有用。我有一个 CodeIgniter 项目,它在我的本地主机上运行得很好。我创建了虚拟主机,以便我可以托管许多项目。我确实获得了网站的第一页(登录页面),但是当登录系统时,我得到了如下所示的错误,而不是下一个有效页面。
Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 127.0.0.1 Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3
这是来自www/site/log.../
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57053] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57053] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57058] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat May 09 01:10:30.703354 2015] [core:error] [pid 5060:tid 1680] [client 127.0.0.1:57058] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
和我的 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /accounting/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
我的虚拟主机设置:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/www/saseco"
ServerName saseco.dev
ServerAlias www.saseco.dev
CustomLog "C:/www/saseco/logs/saseco.local.access.log" combined
ErrorLog "C:/www/saseco/logs/saseco.local.error.log"
<Directory "C:/www/saseco">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
我的登录控制器的部分片段:
function user_login()
{
if(isset($_POST['enter'])) //Login button pressed
{
$data = $_POST;
$check = $this->login_model->login_match($data);
谁能告诉我哪里做错了?
好的,所以在代码中您没有向我们展示 - 您需要在创建 http://127.0.0.1/saseco/login/user_login
的位置更改它并使其生成 http://www.saseco.dev/login/user_login
因为根据您的虚拟主机,这是两个截然不同的位置设置。
所以你需要有类似 <?php echo base_url('login/user_login');?>
的东西
并确保在 /application/config/config.php 中正确配置了 $config['base_url']。
尝试
$config['base_url'] = '';
或硬编码为
$config['base_url'] = 'http://www.saseco.dev/';
补充: 不确定为什么将 RewriteBase 设置为会计,因此请尝试更改
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /accounting/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
至
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
<?
?>
试试这个:
<?php
?>
对我有用。