在一个位置更改链接的目录路径

I've got a website which I need to move across to another server, however i've got a problem with the directory paths and how they've been setup throughout the whole site.

So on every page, there're includes that look like the following

<?php include($_SERVER['DOCUMENT_ROOT'].'/views/includes/header.php'); ?>

This setup works perfectly fine on its own server because the DOCUMENT_ROOT is fine, however, the issue i've ran into is that i've just brought this down onto my localhost where the DOCUMENT_ROOT is

/Applications/MAMP/htdocs

when i need it to look like this

/Applications/MAMP/htdocs/website-name

Is there anywhere in the Perch CMS or .htaccess where i can perhaps change the DOCUMENT_ROOT or otherwise without having to amend every single link?

Thanks.

If you have mod_rewrite activated in Apache, you could use a rewrite rule in .htaccess.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

$_SERVER is a global variable. You could also override it in an entry point PHP script.

I guess you're using the free MAMP where setting up hosts is a manual task? Now you're running the site in a subdirectory of the root, right?

I strongly recommend always running the CMS in the root. Running CMS in a subdomain is always trouble, in my experience. Also, you want your local and remote setup to be as similar as possible.

With MAMP PRO it's very easy to set up multiple roots, it's a good investment to avoid the hassle with manual apache configs. Works flawlessly.