I have downloaded an instance of a website which was architected in PHP. I would like to use MAMP to manage it.
When I go to localhost to try to access the site I get:
Not Found The requested URL /en/ was not found on this server.
In the site/folder structure there is a rootfile.php
which points to a config.php
which I believe is routing the site depending on the environment.
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;
}
}
Any ideas?
I'm afraid that this config.php file does not redirect, nor does it give any hints towards how the application handles routing and what causes the error. It merely defines certain constants that seem to serve as configuration (for different environments) for the application handled by this file.
If I had to guess, I would say that you've not configured your virtual host properly. The error message refers to a /en/ URL. It looks like that message comes from your webserver, not your PHP application. Since the URL doesn't mention a specific file (ending in .html or .php) I'd guess the application is made to have all requests routed to a single entrypoint. That could be the rootfile.php you mentioned or more commonly a file like public/index.php. If your virtual host isn't set up properly, however, any redirect to an /en/ URL would make the webserver actually look for an /en directory.
Looking online I find that MAMP stores its vhost config in Applications/MAMP/conf/apache/httpd.conf. There you need to ensure that everything gets redirected to whatever entrypoint your application has. See Prix's answer at https://serverfault.com/a/188411/443858