問題描述
大約一周前,我在一個新網(wǎng)站的測試環(huán)境中工作.我離開了一個小時,回來了,現(xiàn)在無法進入管理頁面,如'http://magento.localhost.com/admin' 導致沒有 404 路由.我是唯一可以訪問它的人,它在任何意義上都不是實時的.我在 Ubuntu 中使用 VBox 來托管環(huán)境.在可能的修復方面,到目前為止我已經(jīng)嘗試過......
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 設(shè)置為 0(如本文和許多其他文章中所述 - http://www.nude-webdesign.com/fix-for-magento-admin-error-404-page-未找到/)
使用/app/code/core/Mage/Core/Controller/Varien/Front.php 方法 _isAdminFrontNameMatched 來顯示 adminPath(它是‘a(chǎn)dmin’)
Playing with the /app/code/core/Mage/Core/Controller/Varien/Front.php method _isAdminFrontNameMatched to display the adminPath (it’s ‘a(chǎn)dmin’)
清除var文件夾,清空瀏覽器緩存.網(wǎng)站的緩存過去和現(xiàn)在都已關(guān)閉.
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.
根據(jù) 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.
在發(fā)生這種情況的那天,我只是在玩一些我復制到我制作的模塊中的布局文件和主題的媒體查詢(所有這些都在這個問題開始發(fā)生之前恢復到它們的原始狀態(tài)).
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).
有人對這里出了什么問題有什么建議嗎?這可能發(fā)生的任何其他可能的原因?
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 建議的輸出意味著我在核心代碼池中的某處創(chuàng)建了一個錯誤(這不是我打算做的事情,與默認代碼搞砸了).不幸的是,為了精確學習,我隨后將其全部替換為 1.7.0.2 的默認核心代碼池.這是在艾倫用我從未調(diào)查過的更多建議更新他的原始答案之前完成的.謝謝艾倫,你太棒了.
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)
最簡單的診斷方法是跳轉(zhuǎn)到 _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
.這讓我覺得你的系統(tǒng)認為它應該尋找一個空名稱的控制器,(可能是默認的控制器值,因為 /admin
(而不是 admin/index
)是您正在使用的網(wǎng)址)
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)
發(fā)生這種情況的原因有很多 - 許多原因都圍繞著核心文件被更改或模塊中的配置節(jié)點設(shè)置為錯誤的值.如果下面的解決方案對您不起作用,您需要嘗試將代碼庫與干凈的代碼庫進行比較,禁用每個自定義模塊,如果修復后重新打開模塊,直到找到問題模塊,或者潛水深入調(diào)試 Magento 路由代碼,找出系統(tǒng)不滿意的原因.
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.
此行為的一個常見原因是為自定義管理路徑設(shè)置的值無效(或根本沒有值)
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/
如果您看到與上述類似的結(jié)果,或者 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
.
如果這不適用于您的系統(tǒng),根據(jù)我的空白控制器理論,我最好的猜測是出于某種未知原因
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.
這篇關(guān)于管理頁面上的 Magento 404的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!