php 管理页面上的 Magento 404
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18724995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento 404 on Admin Page
提问by ooblek6000
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…
大约一周前,我在一个新站点的测试环境中工作。我离开了一个小时,回来了,现在无法进入管理页面,如在“ http://magento.localhost.com/admin”中的结果为 No Route 404。我是唯一可以访问此页面的人,它在任何意义上都不是活的。我在 Ubuntu 中使用 VBox 来托管环境。在可能的修复方面,到目前为止我已经尝试过......
Making sure core_store, core_store_group, core_website, and customer_group table ids are set to 0 (as described in this and many other articles - http://www.nude-webdesign.com/fix-for-magento-admin-error-404-page-not-found/)
Playing with the /app/code/core/Mage/Core/Controller/Varien/Front.php method _isAdminFrontNameMatched to display the adminPath (it's ‘admin')
Cleared the var folder, emptied browser cache. Site's caching was and is turned off.
Adding 'index.php' to the url still results in a 404.
As per Magento Admin 404, the file 'app/etc/use_cache.ser' doesn't exist for me.
确保 core_store、core_store_group、core_website 和 customer_group 表 ID 设置为 0(如本文和许多其他文章中所述 - http://www.nude-webdesign.com/fix-for-magento-admin-error-404-未找到页面/)
使用 /app/code/core/Mage/Core/Controller/Varien/Front.php 方法 _isAdminFrontNameMatched 来显示 adminPath(它是“admin”)
清除 var 文件夹,清空浏览器缓存。站点的缓存过去和现在都关闭。
将 'index.php' 添加到 url 仍然会导致 404。
根据Magento Admin 404,我不存在文件“app/etc/use_cache.ser”。
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?
有没有人对这里有什么问题有任何建议?这可能发生的任何其他可能的原因?
Thanks for anything.
感谢任何事情。
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:
编辑 1:06pm 9/10/2013:为了响应 Alan Storm 的检索 Standard.php 正在寻找的控制器名称的方法,我收到了许多“丢失”的控制器文件。但是,在下载 1.7.0.2 的新副本以找到这些文件后,它们也不存在于其中。这是我在 Standard.php 中 Alan 的 var_dump 建议的输出:
..."/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/Paypal/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/Authorizenet/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/Compiler/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/ImportExport/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/XmlConnect/controllers/Adminhtml/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/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/IndexController.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/Paypal/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/Authorizenet/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/Compiler/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/ImportExport/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/XmlConnect/controllers/Adminhtml/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/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/IndexController.php”
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.
2013 年 9 月 10 日下午 3:39 已解决:好的,它已修复,尽管很直白。我认为 Alan Storm 的 var_dump 建议的输出意味着我在核心代码池中的某个地方创建了一个错误(这不是我打算做的事情,与默认代码搞砸了)。不幸的是,为了精确学习,我随后将其全部替换为 1.7.0.2 的默认核心代码池。这是在艾伦用我从未调查过的更多建议更新他的原始答案之前完成的。谢谢艾伦,你真棒。
回答by Alan Storm
A no route 404 error usually indicates Magento can't find the controller file it thinks it should load (usually due to a misconfiguration)
no route 404 错误通常表示 Magento 找不到它认为应该加载的控制器文件(通常是由于配置错误)
The easiest way to diagnose this is to hop to _validateControllerClassName
诊断这个最简单的方法是跳到 _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;
}
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.
并var_dump
在 returnfalse
语句周围删除一些日志记录或s 。这应该会告诉您 Magento 正在寻找哪些文件而无法找到 - 通常足以指出问题所在。
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;
}
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.
更新:Magento 在多个位置查找控制器文件是正常的——每个注册为包含 adminhtml 控制器文件的模块都需要检查。
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)
但是,几乎所有要查找的控制器文件都命名为/Controller.php
. 对于默认/admin
索引页面,这应该是IndexController.php
. 这让我觉得你的系统认为它应该寻找一个空白名称的控制器,(可能是默认控制器值,因为/admin
(而不是admin/index
)是你正在使用的 URL)
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.
发生这种情况的原因有很多——许多原因是核心文件被更改或模块中的配置节点设置了错误的值。如果下面的解决方案对您不起作用,您需要尝试将代码库与干净的代码库进行比较,禁用每个自定义模块,如果修复问题,则重新打开模块,直到找到问题模块,或潜水深入调试 Magento 路由代码以找出您的系统不满意的原因。
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.
如果“自定义管理路径”的值为空,或者包含和附加/
,这可能会干扰路由。
Since you can't access the admin, try running the following SQL query
由于您无法访问管理员,请尝试运行以下 SQL 查询
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/
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.
如果您看到与上述类似的结果,或者admin/url/custom_path
是空白/不存在但admin/url/use_custom_path
仍然存在1
— 那么这就是您的问题。
Try deleting these configuration values (admin/url/use_custom_path
) and (admin/url/use_custom_path
) from core_config_data
.
尝试从 中删除这些配置值 ( admin/url/use_custom_path
) 和 ( admin/url/use_custom_path
) core_config_data
。
If that doesn't apply to your system, per my blank controller theroy my best guess would be for some unknown reasonthe 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'
));
}
is populating the controller
key with a blank value.
正在controller
用空值填充键。
回答by Ricardo Martins
In my case, my admin was giving me 404 because there's no store set. I solved it by running the following query
就我而言,我的管理员给了我 404,因为没有商店集。我通过运行以下查询解决了它
SET SQL_SAFE_UPDATES=0;
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
SET SQL_SAFE_UPDATES=1;
You can check if you get the below error logged in var/log/system.log
您可以检查是否在 var/log/system.log 中记录了以下错误
ERR (3): Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /.../app/code/core/Mage/Core/Model/App.php on line 634 and defined in /.../app/code/core/Mage/Core/Model/Store.php on line 395
ERR (3): 可恢复错误:传递给 Mage_Core_Model_Store::setWebsite() 的参数 1 必须是 Mage_Core_Model_Website 的实例,给定 null,在 /.../app/code/core/Mage/Core/Model/App.php 中调用在第 634 行并在第 395 行的 /.../app/code/core/Mage/Core/Model/Store.php 中定义
回答by Keyur
Before anything check your configuration file ( app/etc/local.xml) and make sure that you have "admin" as value for the frontName
tag.
ex.:
在进行任何检查之前,请检查您的配置文件 (app/etc/local.xml) 并确保您将“admin”作为frontName
标签的值。前任。:
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
Usually when you try http://yoursite.com/adminit gives you the admin area Try using an url like that http://yoursite.com/index.php/adminand if it works probably you need to only modify the rewrite rules or follow the suggestions (see the link below)
通常,当您尝试http://yoursite.com/admin 时,它会为您提供管理区域尝试使用类似http://yoursite.com/index.php/admin的网址 ,如果它有效,您可能只需要修改重写规则或遵循建议(见下面的链接)
回答by ahe_borriglione
I got this problem on a shop with custom admin url www.shop.com/customadminroute/ and System -> Configuration -> Web -> URL options -> Add Store Code to Urls: Enabled
我在使用自定义管理网址 www.shop.com/customadminroute/ 和系统 -> 配置 -> 网页 -> URL 选项 -> 将商店代码添加到网址的商店中遇到此问题:已启用
In this case the following module should fix it:
在这种情况下,以下模块应该修复它:
https://github.com/romfr/404adminlogin
https://github.com/romfr/404adminlogin
Thanks to Blog post of Carmen Bremen:
感谢 Carmen Bremen 的博客文章:
http://neoshops.de/2012/09/07/magento-404-fehlerseite-beim-admin-login/
http://neoshops.de/2012/09/07/magento-404-fehlerseite-beim-admin-login/