Question

I am testing my website code, and I have the following folders in my working directory:

  • css
  • js
  • img
  • html (contains index.html)

When I try to bring up my website locally (the "index.html" inside of the html folder), none of the css or js files were found (404 Error).

However, before I made an html folder everything was linked together fine, and my file setup looked like this:

  • css
  • js
  • img
  • index.html

Also, when I created an "html" folder and put "index.html" inside of it, I changed the html code so that it would refer to the other files appropriately (from what I've seen on various websites):

<link href="../css/my_styles.css" rel="stylesheet" type="text/css" />  
<script type="text/javascript" src="../js/touch_functionality.js"></script>
<img src="../img/display_photo.jpg" alt="Display Photo">

Additional Information:

I am using a local Apache server to access the "index.html" file, and I have set the DocumentRoot for the VirtualHost I made to the "/html" folder.

Additionally, I thought this may have been a permissions error, but I downloaded Cygwin and I used "chmod 711" on all of the folders in my working directory and I have used "chmod 644" on the "index.html" file inside of the html folder, but the files still wouldn't be found.

I've done my research on this for quite a few hours, but unfortunately I haven't come across a solution for this yet. Any help would be much appreciated, thank you.

Update

If I change the DocumentRoot to where all of my working space directory (instead of html) and place a .php file that simply contains the following line of code:

<?php require("html/index.html"); ?>

where my folders reside so my working directory looking like this:

-css

-js

-img

-html (contains index.html)

-index.php

Everything will work correctly. However, I would have to believe there is a way so that I don't have to do this "work-around" method. Any insight would be incredibly helpful, thanks again.

Was it helpful?

Solution

The reason being is that the web server only allows one to view files in the html directory or below.

Otherwise it will somebody to access any part of your file system.

Would you like that?

To fix this go back to the configuration that works,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top