Page 1 of 1

Development mirroring Production

PostPosted: 26. September 2005 14:46
by jazzsnob
How can I make the installation of XAMPP on my desktop just like the production server?

I want to be able to code like this:

<img src="/images/image1.jpg" />

this way no matter if the image is called from the root directory or 3 directories in, the image works, or the include, etc.

I'm trying to avoid using:

<img src="../images/image1.jpg" />

If I have that with a CSS file and the CSS file has background images being called up they will only work from the root.

Thanks in advance...

PostPosted: 26. September 2005 14:51
by Wiedmann
I want to be able to code like this:
Code: Select all
<img src="/images/image1.jpg" />

Where is your problem with this code?

PostPosted: 26. September 2005 16:15
by jazzsnob
There is no problem with that code, but I can't get that code to work on my development on my laptop. It works on the production server.

I want to configure APACHE so I can use that code and have it work, as of now the path is directories deep and I don't know how to change that.

Thank you for the response.

PostPosted: 26. September 2005 16:39
by Wiedmann
There is no problem with that code, but I can't get that code to work on my development on my laptop.

Why not? I have no problem with this code on my local xampp.

Code: Select all
<img src="/images/image1.jpg" />

This is a URI. The starting point from a URI ("/") in your filesystem is the directory specified by DOCUMENT_ROOT.

So, if you put your files on both servers into DOCUMENT_ROOT, this code works on your production and your local server without problems.

PostPosted: 26. September 2005 17:01
by jazzsnob
If I knew I wouldn't be asking ;)

Is there anything in the apache configuration file that I need to change maybe?

Thanks for helping, I truly appreciate it.


----------------------------------------

Here is the URL:
http://localhost/showus/

Here is the error I'm getting:
Warning: main(/includes/cstring.php) [function.main]: failed to open stream: No such file or directory in C:\apachefriends\xampp\htdocs\showus\index.php on line 2

If I change the include from:
include '/includes/cstring.php';

to:
include '../includes/cstring.php';

it works...???

PostPosted: 28. September 2005 21:13
by Wiedmann
include '/includes/cstring.php';

Oh, you mean PHP includes? That's another situation. PHP works directly with the filesystem. A "/" in front of a path is the root of your harddisk. So, it's not really good to use absolute paths in the scripts. Because you don't know the real path for every target system.

include '../includes/cstring.php';

This should work on every server.

Or you can use a variable in top of your script and change this variable on every server:
Code: Select all
$installpath = '/foo/bar';
include $installpath.'/includes/cstring.php';


Or, if you have all files in/above DocumentRoot:
Code: Select all
include $_SERVER['DOCUMENT_ROOT'].'/includes/cstring.php';