Magento 404 on Admin Page(管理页面上的 Magento 404)
问题描述
大约一周前,我在一个新网站的测试环境中工作.我离开了一个小时,回来了,现在无法进入管理页面,如'http://magento.localhost.com/admin' 导致没有 404 路由.我是唯一可以访问它的人,它在任何意义上都不是实时的.我在 Ubuntu 中使用 VBox 来托管环境.在可能的修复方面,到目前为止我已经尝试过......
About a week ago, I was working in a test environment for a new site. I left for an hour, came back, and now cannot get to the admin page, as in ‘http://magento.localhost.com/admin’ results in a No Route 404. I am the only one with access to this, it is not live in any sense. I am using VBox with Ubuntu to host the environment. In terms of possible fixes, so far I have tried…
确保 core_store、core_store_group、core_website 和 customer_group 表 ID 设置为 0(如本文和许多其他文章中所述 - http://www.nude-webdesign.com/fix-for-magento-admin-error-404-page-未找到/)
使用/app/code/core/Mage/Core/Controller/Varien/Front.php 方法 _isAdminFrontNameMatched 来显示 adminPath(它是‘admin’)
Playing with the /app/code/core/Mage/Core/Controller/Varien/Front.php method _isAdminFrontNameMatched to display the adminPath (it’s ‘admin’)
清除var文件夹,清空浏览器缓存.网站的缓存过去和现在都已关闭.
Cleared the var folder, emptied browser cache. Site’s caching was and is turned off.
将index.php"添加到 url 仍然会导致 404.
Adding 'index.php' to the url still results in a 404.
根据 Magento Admin 404,文件app/etc"/use_cache.ser' 对我来说不存在.
As per Magento Admin 404, the file 'app/etc/use_cache.ser' doesn't exist for me.
在发生这种情况的那天,我只是在玩一些我复制到我制作的模块中的布局文件和主题的媒体查询(所有这些都在这个问题开始发生之前恢复到它们的原始状态).
On the day of this occurring, I was simply playing around with some layout files I had copied to a module I made and the theme’s media queries (all of which were reverted to their original state even before this problem started to occur).
有人对这里出了什么问题有什么建议吗?这可能发生的任何其他可能的原因?
Does anyone have any suggestions as to what is wrong here? Any other possible reasons this could be happening?
谢谢你的一切.
EDIT 1:06pm 9/10/2013: 为了响应 Alan Storm 的检索 Standard.php 正在寻找的控制器名称的方法,我收到了许多丢失"的控制器文件.但是,在下载 1.7.0.2 的新副本以找到这些文件后,它们也不存在于其中.这是我在 Standard.php 中 Alan 的 var_dump 建议的输出:
EDIT 1:06pm 9/10/2013: In response to Alan Storm's method of retrieving controller names that Standard.php is looking for, I was returned many "missing" controller files. However, after downloading a fresh copy of 1.7.0.2 to find those files, they weren't present in their either. Here is my output from Alan's var_dump suggestion in Standard.php:
..."/public_html/app/code/core/Mage/Index/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Index/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Paygate/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Paygate/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Paypal/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Paypal/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Widget/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Widget/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Oauth/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Oauth/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Authorizenet/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Authorizenet/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Bundle/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Bundle/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Centinel/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Centinel/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Compiler/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Compiler/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Connect/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Connect/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Downloadable/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Downloadable/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/ImportExport/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/ImportExport/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Api2/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Api2/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/PageCache/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/PageCache/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/XmlConnect/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/XmlConnect/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Adminhtml/controllers/Controller.php"
..."/public_html/app/code/core/Mage/Adminhtml/controllers/Controller.php"
..."/public_html/app/code/community/Phoenix/Moneybookers/controllers/Controller.php"
..."/public_html/app/code/community/Phoenix/Moneybookers/controllers/Controller.php"
..."/public_html/app/code/core/Mage/Captcha/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/Captcha/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/Controller.php"
..."/public_html/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/IndexController.php"
..."/public_html/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/IndexController.php"
已于 2013 年 9 月 10 日下午 3:39 解决: 好的,它已修复,尽管很直白.我认为 Alan Storm 的 var_dump 建议的输出意味着我在核心代码池中的某处创建了一个错误(这不是我打算做的事情,与默认代码搞砸了).不幸的是,为了精确学习,我随后将其全部替换为 1.7.0.2 的默认核心代码池.这是在艾伦用我从未调查过的更多建议更新他的原始答案之前完成的.谢谢艾伦,你太棒了.
Resolved 3:39pm 9/10/2013: Ok, it's fixed albeit rather bluntly. I took the output of Alan Storm's var_dump suggestion to mean I had created an error somewhere in the core code pool (which is not something I intended on doing, screwing with the default code that is). Unfortunately for sake of exact learning, I then replaced it all with the default core code pool of 1.7.0.2. This was done before Alan updated his original answer with more suggestions that I never investigated. Thanks Alan, you're rad.
推荐答案
无路由 404 错误通常表示 Magento 找不到它认为应该加载的控制器文件(通常是由于配置错误)
A no route 404 error usually indicates Magento can't find the controller file it thinks it should load (usually due to a misconfiguration)
最简单的诊断方法是跳转到 _validateControllerClassName
The easiest way to diagnose this is to hop to _validateControllerClassName
#File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
protected function _validateControllerClassName($realModule, $controller)
{
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
return false;
}
// include controller file if needed
if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
return false;
}
return $controllerClassName;
}
并在返回的 false
语句周围删除一些日志记录或 var_dump
.这应该会告诉您 Magento 正在寻找哪些文件但找不到哪些文件 - 通常足以指出问题所在.
and drop some logging or var_dump
s around the return false
statments. This should tell you which files Magento is looking for and can't find — it's usually enough to point to the problem.
if (!$this->validateControllerFileName($controllerFileName)) {
var_dump($controllerFileName);
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
var_dump($controllerClassName);
return false;
}
// include controller file if needed
if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
var_dump("Couldn't include: $controllerFileName");
return false;
}
更新:Magento 在多个位置查找控制器文件是正常的——每个注册为包含 adminhtml 控制器文件的模块都需要检查.
Update: It's normal for Magento look for the controller file in multiple places — every module that registered as containing adminhtml controller files needs to be checked.
然而,几乎所有要查找的控制器文件都被命名为/Controller.php
.对于默认的 /admin
索引页面,它应该是 IndexController.php
.这让我觉得你的系统认为它应该寻找一个空名称的控制器,(可能是默认的控制器值,因为 /admin
(而不是 admin/index
)是您正在使用的网址)
However, almost all the controller files being looked for are named /Controller.php
. For the default /admin
index page this should be IndexController.php
. This makes me think your system thinks it's supposed to look for a controller with a blank name, (likely the default controller value since /admin
(and not admin/index
) is the URL you're using)
发生这种情况的原因有很多 - 许多原因都围绕着核心文件被更改或模块中的配置节点设置为错误的值.如果下面的解决方案对您不起作用,您需要尝试将代码库与干净的代码库进行比较,禁用每个自定义模块,如果修复后重新打开模块,直到找到问题模块,或者潜水深入调试 Magento 路由代码,找出系统不满意的原因.
There's myriad reasons this could happen — many revolving around a core file being changed or a configuration node in a module set to the wrong value. If the solutions below don't work for you you'll need to try diff-ing your code base vs. a clean one, disabling every custom module and if that fixing things turn modules back on until the problem module is found, or dive deep into debugging Magento routing code to figure out why your system is unhappy.
此行为的一个常见原因是为自定义管理路径设置的值无效(或根本没有值)
One common cause for this behavior is an invalid value (or no value at all) being set for a custom admin path at
System -> Configuration -> Admin -> Admin Base URL -> Use Custom Admin Path
如果自定义管理路径"的值为空,或者包含额外的 /
,这可能会干扰路由.
If the value for "custom admin path" is blank, or contains and additional /
, this could be interfering with the routing.
由于您无法访问管理员,请尝试运行以下 SQL 查询
Since you can't access the admin, try running the following SQL query
select * from core_config_data where path like '%custom_path%';
...
292 default 0 admin/url/use_custom_path 1
293 default 0 admin/url/custom_path admin/
如果您看到与上述类似的结果,或者 admin/url/custom_path
为空/不存在但 admin/url/use_custom_path
仍然是 1
——那是你的问题.
If you see results similar to the above, or admin/url/custom_path
is blank/not-present but admin/url/use_custom_path
is still 1
— then that's your problem.
尝试从 core_config_data
中删除这些配置值 (admin/url/use_custom_path
) 和 (admin/url/use_custom_path
).
Try deleting these configuration values (admin/url/use_custom_path
) and (admin/url/use_custom_path
) from core_config_data
.
如果这不适用于您的系统,根据我的空白控制器理论,我最好的猜测是出于某种未知原因
If that doesn't apply to your system, per my blank controller theroy my best guess would be for some unknown reason the code at
#File: app/code/core/Mage/Core/Controller/Varien/Router/Admin.php
public function fetchDefault()
{
// set defaults
$d = explode('/', $this->_getDefaultPath());
$this->getFront()->setDefault(array(
'module' => !empty($d[0]) ? $d[0] : '',
'controller' => !empty($d[1]) ? $d[1] : 'index',
'action' => !empty($d[2]) ? $d[2] : 'index'
));
}
正在用空白值填充 controller
键.
is populating the controller
key with a blank value.
这篇关于管理页面上的 Magento 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:管理页面上的 Magento 404
基础教程推荐
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01