directory paths

2 posts / 0 new
Last post
#1 Fri, 09/12/2008 - 20:30
bhm8hwcm

directory paths

I was wondering if there is some kind of configuration settings for relative paths.

I moved a site over from another host and my relative paths in php includes do not work.

eg. include '../file.php'

must now be changed to '../../file.php' in order for it to work

Nothing else has changed (ie files relative to one another).

Any ideas?

Mon, 09/15/2008 - 11:23
joes

In short, what you're saying makes no sense.
You're not providing good information to provide an answer.

>>Nothing else has changed (ie files relative to one another).
If that were the case there would not be a problem.
It sounds like you did change relative paths, otherwise it makes no sense to have to change ../file.php to ../../file.php. That is a relative path change.

I'll waste some time here and try and guess what you're doing.

You had a site whose directory structure was similar to;
/var/www
/var/www/html
/var/www/apptomove

containing files which looked something like;
/var/www/file.php
/var/www/apptomove/index.php - with an include line of ../file.php

You moved this entire site to;
/var/www/html/moved_app
Now you don't want your file.php to reside in /var/www/html

If this is the case you didn't only move the site you want to change the relative directory structures also.

Apache rewrite (and other web server re-writers) only work for html.
PHP with html template including <img src=/images/images.jpg> will follow apache rewrites only because it's html and the request comes back from the client browser.
PHP includes will not follow apache rewrite rules.
HTML source embedded or constructed in PHP can use the rewrites.

An easy and standard fix uses Apache rewrite.
move site to /var/www/moved_app - file.php resides in /var/www
/var/www/html/index.php is the standard home page accessed as; www.domain.com/index.php

use Apache rewrite to rewrite newsite to a subdir accessed as;
www.domain.com/moved_app/index.php

If this is not the case, please provide more information.
What was the original directory structure?
What is the new directory structure?
How do you want to construct the URL to access this new directory?

You could kludge/fix this with rewrite, symlinks, PHP variables in PHP files, PHP variables in server conf and probably a few other ways, each with their own issues.

I may be totally off-base here, it's hard to help without more information.

Topic locked