I'm working to migrate a PHP site from one server at Godaddy to another. The site has a lot of "legacy" code in it, with links to images, css, etc. in the format:
<img src="/img/img.png" />
and required/included content like...
require_once($_SERVER['DOCUMENT_ROOT']."/_inc/required-stuff.php");
The problem I have is the current site is "www.mycurrentsite.com" and when I set up a new account in the cPanel stuff it created something like..
111.111.111.111/~mycurrentsite/
So all the items starting with "/" and the $_SERVER['DOCUMENT_ROOT'] do not point to the right spot.
I've read about setting up a host, but that will only get me to the ip, not the "~substuff" area. I know there has to be something faster than going in and rewriting everything or setting a variable = "~mycurrentsite/" that I put in at the front of everything and set to "" when I go live.
I'm at a loss and willing to take the down votes I'll probably get for "not researching" after spending the last couple hours trying to find a solution.
When I look at where $SERVER['DOCUMENT_ROOT'] currently points on the setup, it's "/usr/local/apache/htdocs". I was able to set the index.html page in this location to at least push any traffic to the IP to the "~mydomain" subfolder, but that doesn't help with the mapping of files.
I'm guessing it may be something in Apache to change but I'm afraid to break something in there since cPanel set it up and most of it says "DO NOT EDIT" in areas that I think I would possible touch.
EDIT: I made changes to the area in my httpd.conf file and set the values I had in the area where ServerName matched the ~mydomain info.
This seems to work, but I'm not confident this is the best way to do it since it has "DO NOT EDIT. AUTOMATICALLY GENERATED..." all over by it. I plan to uncomment my changes and put back what was there before I roll the DNS, but for now, it seems like A solution, if not the best one.
EDIT:
I ran into this problem again and while editing the VirtualHost options manually in the apache http.conf file I realized I could set up different ports for each site. I now set up a.domain.com on port :80 and b.domain.com on port :8080, etc.
Worked like a charm. the one issue I ran into next was with PHP sessions being read by the different sites, but this was set by updating in the code like so...
ini_set('session.name', 'DOMAIN1'); // session name for a.domain.com
HTH save someone else some time.