我下载了一个用PHP构建的网站实例。我想用MAMP来管理它。
当我进入本地主机尝试访问该站点时,我得到了:
Not Found The requested URL /en/ was not found on this server.
在站点/文件夹结构中,有一个rootfile.php
指向一个config.php
,我相信它会根据环境路由该站点。
config.php
<?php
// error_reporting(E_ALL);
// ini_set("display_errors", 1);
session_start();
$validLanguages = array('EN'=>'en','DE'=>'de'/*,'RU'=>'ru','PT'=>'pt','HU'=>'hu','NL'=>'nl'*/);
switch ($_SERVER['SERVER_NAME'])
{
case'127.0.0.1':
{
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
define('ROOT_PATH', '/Users/antonio-pavicevac-ortiz/Dropbox/developer_folder/__work__/fragrances.christinaaguilera.dev/');
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/fragrances.christinaaguilera.dev/');
define('MEDIA_ROOT_URL','http://127.0.0.1/Users/antonio-pavicevac-ortiz/Dropbox/developer_folder/__work__/fragrances.christinaaguilera.dev/');
define('CSS_ROOT_URL', ROOT_URL.'css/');
define('JS_ROOT_URL', ROOT_URL.'js/');
define('IMG_ROOT_URL', ROOT_URL.'images/');
break;
}
case'192.168.0.206':
{
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
define('ROOT_PATH', '/media/sf_public_html/aguilera-microsite/branches/20141007_responsive/');
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/aguilera-microsite/branches/20141007_responsive/');
define('MEDIA_ROOT_URL','http://192.168.0.206/aguilera-microsite/branches/20141007_responsive/');
define('CSS_ROOT_URL', ROOT_URL.'css/');
define('JS_ROOT_URL', ROOT_URL.'js/');
define('IMG_ROOT_URL', ROOT_URL.'images/');
break;
}
case'137.183.87.135':
{
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
define('ROOT_PATH', '/content/aguilera/docs/responsive/');
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/responsive/');
define('MEDIA_ROOT_URL','http://137.183.87.135:4064/content/aguilera/docs/responsive/');
define('CSS_ROOT_URL', ROOT_URL.'css/');
define('JS_ROOT_URL', ROOT_URL.'js/');
define('IMG_ROOT_URL', ROOT_URL.'images/');
break;
}
case'137.183.87.139':
{
// error_reporting(E_ALL);
// ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
define('ROOT_PATH', '/content/aguilera/docs/restage/');
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/restage/');
define('MEDIA_ROOT_URL','http://137.183.87.139:4064/restage/');
define('CSS_ROOT_URL', MEDIA_ROOT_URL.'css/');
define('JS_ROOT_URL', MEDIA_ROOT_URL.'js/');
define('IMG_ROOT_URL', MEDIA_ROOT_URL.'images/');
break;
}
case'137.183.87.140':
{
// error_reporting(E_ALL);
// ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
define('ROOT_PATH', '/content/aguilera/docs/restage/');
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/restage/');
define('MEDIA_ROOT_URL','http://137.183.87.140:4064/restage/');
define('CSS_ROOT_URL', MEDIA_ROOT_URL.'css/');
define('JS_ROOT_URL', MEDIA_ROOT_URL.'js/');
define('IMG_ROOT_URL', MEDIA_ROOT_URL.'images/');
break;
}
default:
{
// error_reporting(E_ALL);
// ini_set("display_errors", 1);
if(substr($_SERVER['HTTP_HOST'],0,7)!='http://')
{
$_SERVER['HTTP_HOST']='http://'.$_SERVER['HTTP_HOST'];
}
if(!preg_match('~elizabetharden~',$_SERVER['HTTP_HOST'])){
// PROD instance root path
define('ROOT_PATH', 'D:/Sites/wwwroot/fragrances.christinaaguilera.com/content/aguilera/docs/restage/');
} else {
// DEV instance root path
define('ROOT_PATH', 'D:/Sites/wwwroot/christinaaguilera.elizabetharden.net/content/aguilera/docs/restage/');
}
define('TEMPLATE_PATH', ROOT_PATH.'templates/');
define('XML_PATH', ROOT_PATH.'xml/');
define('ROOT_URL', $_SERVER['HTTP_HOST'].'/');
if(isset($_SERVER["HTTP_SSL"])){
// define('MEDIA_ROOT_URL','https://secure.footprint.net/perfumes-christinaaguilera-com/restage/v_23/');
} else {
// define('MEDIA_ROOT_URL','http://media.perfumes.christinaaguilera.com/restage/v_23/');
}
define('MEDIA_ROOT_URL','/');
define('CSS_ROOT_URL', MEDIA_ROOT_URL.'css/');
define('JS_ROOT_URL', MEDIA_ROOT_URL.'js/');
define('IMG_ROOT_URL', MEDIA_ROOT_URL.'images/');
break;
}
}
有什么想法吗?
答案 0 :(得分:1)
恐怕此config.php文件不会重定向,也不会提示应用程序如何处理路由以及导致错误的原因。它仅定义了某些常量,这些常量似乎可以作为此文件处理的应用程序的配置(用于不同的环境)。
如果我不得不猜测,我会说您没有正确配置虚拟主机。该错误消息指向一个/ en / URL。看起来该消息来自您的网络服务器,而不是您的PHP应用程序。由于URL并未提及特定文件(以.html或.php结尾),因此我猜想该应用程序具有将所有请求路由到单个入口点的功能。那可能是您提到的rootfile.php,或更常见的是像public / index.php这样的文件。但是,如果您的虚拟主机设置不正确,则任何重定向到/ en / URL的重定向都将使Web服务器实际上寻找/ en目录。
在线查看,我发现MAMP将其虚拟主机配置存储在Applications / MAMP / conf / apache / httpd.conf中。在那里,您需要确保所有内容都重定向到应用程序具有的任何入口点。在Prix上查看https://serverfault.com/a/188411/443858的答案