Assigning new domain breaks PHP scripts and re-written URLs: help

I have built a dynamic site with a lot of PHP includes.

It does not have a database but I have used a lot of ‘conditional includes’ and other scripts to load the correct html files into the larger template so that I do not have to re-write tons of html on every page.

The ‘conditional includes’ depend on a query string and therefore the $_GET array to determine which html file to load into that particular place.

I also have an .htaccess file in which the index page is set and all the URLs are re-written for ease of readabilty/searchability
i.e. http://www.mydomain.com/index.php?nav=services re-writes to
http://www.mydomain.com/services/

I have built the site inside a sub-directory of my client’s current site because the new site is a updated and improved design of his old site. Having it in the sub-directory has enabled me to test it live without interfering with his current site, which he relies on for business. Let’s call the sub-directory http://www.mydomain.com/2010_New_Website/
The recently completed website functions fully within this sub-directory, including the re-written URLS.

He also owns another domain which is unused, let’s call it www.otherdomain.com
He wants to use it to test out the new site. I’ve gone into the host’s control panel and assigned otherdomain.com to the /2010_New_Website/ sub-directory.

If I navigate to www.otherdomain.com only half of the content loads. I have turned PHP errors on for this domain, and updated to PHP 5 (which was the version of PHP in the subdirectory) and it’s throwing PHP errors all over the place and not loading the content. The only includes that are working in my index.php file are the ones that are not conditional. All the conditional ones fail. To test, I write PHP code into the index file to echo the $_GET variable. It doesn’t display. On other pages my scripts are broken.

Can somebody please tell me what could have happened; why navigating this site with the new domain in the address bar breaks everything? Thanks.

I have found that if I type www.otherdomain.com/services/ then my conditional includes don’t load. If I type www.otherdomain.com/index.php?nav=services then stuff DOES load.

To test this further, I wrote a small piece of PHP code into the index.php file: echo $_GET[‘nav’];
When I write www.otherdomain.com/index.php?nav=services it prints ‘services’ in the web page.
When I write www.otherdomain.com/services/ it prints ‘/services’ in the web page.
So perhaps it has something to so with that leading forward-slash. Where does that come from?

I generally find paying attention to the displayed errors is informative :shifty:

Why not just put the new site in the web root folder of otherdomain, instead of pointing it at some subdirectory on another domain and then having to contend with the additional redirection of the hosting control panel as another potential source of your rewrite issue?

I think that after changing your domain name for the same project that would be better to reinstall everything. Each web application. I believe that would be another guarantee something will work great on your end.

I solved the problem by taking the last forward-slash off the address (the address of the sub-directory) that I assigned to the new domain in the host’s control panel. So instead of /www/2010_New_Website/ I wrote /www/2010_New_Website Solved.