我在服务器上有一个有效的cakephp网站。我已将其下载到我的localhost目录。似乎路线设置不正确,但我不知道应该改变什么。在我的routes.php文件中,我有:
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* search controller
*/
Router::connect('/search', array('controller' => 'search', 'action' => 'index'));
/**
* offer controller
*/
Router::connect('/offers', array('controller' => 'offers', 'action' => 'index'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
请告诉我是否需要发布更多信息。我的localhost设置非常标准,我将每个项目都放在一个单独的文件夹中(例如,远程服务器上的localhost / myproject / ..就像www.mydomain.com/projects/myproject/)我使用Softaculous App Installer来设置远程项目目录,我使用在线IDE编辑它,所以以前从未在我的localhost服务器上的文件。现在把它们拉下来。 Woudl感谢任何人提供的任何帮助。
由于
更新:
$ _ SERVER ['SERVER_NAME']正在lib / Cake / TestSuite / CakeTestSuiteDispatcher.php中设置,如果它有帮助......
/**
* Parse URL params into a 'request'
*
* @return void
*/
protected function _parseParams() {
if (!$this->_paramsParsed) {
if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
foreach ($this->params as $key => $value) {
if (isset($_GET[$key])) {
$this->params[$key] = $_GET[$key];
}
}
if (isset($_GET['code_coverage'])) {
$this->params['codeCoverage'] = true;
$this->_checkXdebug();
}
}
if (empty($this->params['plugin']) && empty($this->params['core'])) {
$this->params['app'] = true;
}
$this->params['baseUrl'] = $this->_baseUrl;
$this->params['baseDir'] = $this->_baseDir;
}
答案 0 :(得分:0)
路线没有造成任何问题。您需要检查服务器名称或基本URL的设置位置(可能是由旧开发人员设置的):
$_SERVER['SERVER_NAME']
或AppController
base-url
存储在数据库中