Root Folder Question (/)

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

Root Folder Question (/)

Postby MoFish » 07. August 2010 15:27

Hi Everyone.

I have a quick question which I hope someone can help me with.

What I would like to achive if possible; is the ability to refference an image and files using only a forward slash; like the following <img src="/image.png" /> for each of my projects.

I have noticed using the / defaults to the htdocs folder as default.

My question is ...

Is there any way possible that I XAMPP will understand the folder I am working in (for example: project1) and set the root as htdocs/project1

If I have another project called project2; and use a forward slash there; it would therefore look for my root to be htdocs/project2.

If anyone knows if this is possible it would be much appriciated.

Thank you.
MoFish
 
Posts: 2
Joined: 07. August 2010 15:21

Re: Root Folder Question (/)

Postby JonB » 07. August 2010 15:46

on the 'web' - in HTTP URL's (and in Linux/Unix) all the slashes are 'forward slashes' and represent folders in the DocumentRoot of Apache.

when you create folders in your XAMPP htdocs folder (the DocumentRoot in XAMMP and below it) - Apache will automatically make the 'back slashes \' Windows uses into 'forward slashes /' when it publishes your website. :)

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Root Folder Question (/)

Postby MoFish » 07. August 2010 15:56

Thanks for the reply.

So what you are suggesting is what exactly?

I am trying to avoid the following <img src="/project1/tick.png" /> which works fine; and would like the following <img src="/tick.png" />

Is there a solution to resolving this issue?

Thanks,
MoFish
 
Posts: 2
Joined: 07. August 2010 15:21

Re: Root Folder Question (/)

Postby JonB » 08. August 2010 01:05

Is there a solution to resolving this issue?


There is no problem is what I am trying to say.

<img src="/tick.png" />


means to Apache: "the file is in the current working directory"

while

<img src="/project1/tick.png" /> "means go to subfolder 'project' and find 'tick.png' "

Is there a solution? Yes, put the file in the same folder. However, if you put everything in one folder - you get a mess.

Generally its considered a poor practice to put much more than the 'launch page' (whatever it may be), favico, and robots.txt in the root of a website.

If you want to have a shared folder for more than one project (so you can have just 'one' tick.png file), you will have to learn about relative versus absolute URL's. (and possibly 'aliases') Most site/application designers have 'common resource' folders for images and navigation elements.

You clearly need to work on understanding file and folder structures. This is about learning HTML/Apache, not solving a XAMMP problem.

:roll:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 121 guests