revlimiter — 2011-11-02T18:23:07-04:00 — #1
I have an issue with how the PHP includes are being picked up on my temporary URLs http://IPADDRESS/~USERNAME/SITENAME/ compared to my live URL http://LIVEDOMAIN.com
The PHP code that I am using is
? include($SERVER['DOCUMENTROOT'] . '/inc/php/header.php'); ?>
and it works great on the live domain because I guess it picks up the DOCUMENT_ROOT as the folder I set that domain up to be in cPanel?
But when I try to load the site on my temporary URL it says that it can't find the PHP include.
I'm on a shared host and I am the owner of many websites which is why they are within my username and sitename folders like that. Should I be using something else other than DOCUMENT_ROOT in order to view both the temporary URL and the live URL correctly?
Hope that makes sense!
ralphm — 2011-11-02T19:04:18-04:00 — #2
Yes, the document root is in a different location in that scenario. My solution to this is to place sites temporarily in a subdomain. E.g. client.mydomain.com
revlimiter — 2011-11-03T17:07:48-04:00 — #3
How would subdomains work for temporary URLs though?
Wouldn't my temporary URL be my shared host IP + username?
In this case http://188.8.131.52/~username/
ralphm — 2011-11-03T19:08:26-04:00 — #4
If you are allowed to set up a subdomain on your own site (and most hosts will let you do that) you could set up a test site at an address like http://dev.mysite.com. Uploading your files there will mean that they will have their own root folder and everything will work as it will when the site is loaded to its final destination.