Development mirroring Production

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Development mirroring Production

Postby jazzsnob » 26. September 2005 14:46

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...
jazzsnob
 
Posts: 3
Joined: 24. September 2005 02:57

Postby Wiedmann » 26. September 2005 14:51

I want to be able to code like this:
Code: Select all
<img src="/images/image1.jpg" />

Where is your problem with this code?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby jazzsnob » 26. September 2005 16:15

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.
jazzsnob
 
Posts: 3
Joined: 24. September 2005 02:57

Postby Wiedmann » 26. September 2005 16:39

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.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby jazzsnob » 26. September 2005 17:01

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...???
jazzsnob
 
Posts: 3
Joined: 24. September 2005 02:57

Postby Wiedmann » 28. September 2005 21:13

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';
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 162 guests