Are HTML and CSS files necessary in the HTDOCS folder for PHP to work in XAMPP?

  • Context: HTML/CSS 
  • Thread starter Thread starter Dave Ritche
  • Start date Start date
  • Tags Tags
    Php
Click For Summary

Discussion Overview

The discussion revolves around the necessity of placing HTML and CSS files in the HTDOCS folder for PHP to function correctly in XAMPP. Participants explore the implications of file placement for web development, particularly in relation to security and server configuration.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • Some participants assert that every file the browser needs to access directly must be located in the HTDOCS folder or its subfolders, including HTML and CSS files.
  • One participant mentions that while PHP code can access files outside the HTDOCS folder, the browser cannot, emphasizing the importance of file placement for accessibility.
  • Another participant highlights security concerns, questioning whether one would want to expose all files on their hard disk to the internet through URL access.
  • There is a suggestion that the Apache server configuration can be modified to allow resources to be stored outside the HTDOCS folder, indicating flexibility in file organization.
  • One participant recommends learning a PHP framework for better management of files and resources.

Areas of Agreement / Disagreement

Participants generally agree that files must be in the HTDOCS folder for direct browser access, but there is disagreement regarding the necessity of this for PHP functionality and the potential for alternative configurations.

Contextual Notes

There are limitations regarding the assumptions about server configuration and security implications that are not fully explored in the discussion.

Dave Ritche
Messages
70
Reaction score
6
Hello everyone..
I am learning php and I'm new to php.I don't know much about it.
i watched a tutuorial on it that told me i were to put my scripts into the HTDOCS folder.
My question is that is it necessary to my html and css files into HTDOCS folder?Will it work?
I am running xampp..
thanks.
 
Technology news on Phys.org
Dave Ritche said:
Hello everyone..
I am learning php and I'm new to php.I don't know much about it.
i watched a tutuorial on it that told me i were to put my scripts into the HTDOCS folder.
My question is that is it necessary to my html and css files into HTDOCS folder?Will it work?
I am running xampp..
thanks.
Every file that the browser has to directly access must be in the HTDOCS folder or a subfolder of HTDOCS.
This applies to a php file that the url refers to.
Also, if your HTML includes statements like:
HTML:
<script src="/somepath/js/directives.js" type="text/javascript"></script>
<link href="/somepath/css/standard.css" rel="stylesheet" type="text/css"/>
then the referenced folders must exist in HTDOCS.

Your can rename the folder (my WAMP version uses www).
Your php code can access files in folders outside the HTDOCS folder. But the browser can't.
 
  • Like
Likes   Reactions: Dave Ritche
Samy_A said:
Every file that the browser has to directly access must be in the HTDOCS folder or a subfolder of HTDOCS.

I'll just add that this is for security reasons. If you made your server accessible to everyone on the Internet (it may actually be that way depending on how your Internet connection is set up!) would you want them to be able to look around everywhere on your hard disk by entering a suitable URL? :wideeyed:
 
  • Like
Likes   Reactions: Dave Ritche
Dave Ritche said:
Hello everyone..
I am learning php and I'm new to php.I don't know much about it.
i watched a tutuorial on it that told me i were to put my scripts into the HTDOCS folder.
My question is that is it necessary to my html and css files into HTDOCS folder?Will it work?
I am running xampp..
thanks.
htdocs is by default set up as your main virtual directory, you can modify your apache server config file to resolve your url to anywhere that your resources are being stored physically. That means you can store your php scripts in the same folder with your html and css. You'd better learn to use a php framework though.
 
  • Like
Likes   Reactions: Dave Ritche

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
3
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K