tags:

views:

42

answers:

3

I have used absolute links throughout my site, the problem comes when I am trying to set up a testing version in a subdirectory on another server. For example, the document structure is /images/image.jpg on the live server, but /subdirectory/images/image.jpg on the testing folder.

What is the solution? Cheers.

+1  A: 

Just do a var_dump($_SERVER) which is a array that stores a lot of server related variables. You will come up with something like

$_SERVER['SERVER_NAME']
$_SERVER['SERVER_PROTOCOL']

read http://php.net/manual/en/reserved.variables.server.php for a list of SERVER vars

sushil bharwani
and what is the aim once these server variables have been attained?
kalpaitch
They give you values like http:// myserver etc so you can combine them http://myserver/index.php
sushil bharwani
+2  A: 

dirty and fast answer: use symlink

Move everything to /images/ and run this :

 ln -s /images/ /subdirectory/images/

clean and slower answer: define a constant on a constant file. Use constants everywhere as a suffix to file location. Change the constant file for live

Best Answer: replicate environments (dev = live).

Stewie
+1  A: 

Don't use subfolders, use subdomains instead. Even on shared hosting you typically have the ability to set these up. It takes all of a few minutes, and you dont have to modify anything in your project.

prodigitalson