Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm pretty new to Linux and Apache and I have a problem with relative paths. I developed my website locally on a Mac, using relative paths and everything worked fine. My files are in a folder with following subfolders:

  • sites
  • css
  • images

Now I'm trying to set up my website on a Linux server running Debian. Almost everything worked out perfectly and I can reach my index.html through the internet. But obviously, relative paths are not working, since I placed my images, my css-file and my other sites in above subfolders, which I try to access with relative paths, but actually they are not working. When I try to access another site (about.html) which is in the sites-folder, I just get this error:

404 Not Found The requested URL /sites/about.html was not found on this server.

For example, from my index.html, I'm trying to access my css-file with this path:

../css/standard.css

I've also implemented external paths, these are working correctly. I'd really appreciate any help or clues. Thank you very much!

share|improve this question
    
What's the error recorded in Apache's error log? I'm not sure that Debian enables the error log by default (I would think it should, but the Linux distros do crazy crap); it should be in /var/log/httpd-error.log or something similar (again, various distros do crazy stuff and I can't memorize them all). –  Chris S Jan 6 '13 at 16:32
    
Thanks to the error-log, I found my mistake: I set one of my subdirectories (sites) as the DocumentRoot, with my index.html placed within this directory. Therefore, apache tried to access my css-file for example through this link: web/sites/css, but it should actually be web/css. Now I just put my index.html into the web-directory (which contains my subdirectories) and link from there to the other directories. Anyway, even though I'm satisfied with this solution, isn't there a way that I could leave the index.html in sites, without changing the DocumentRoot? @Chris S: Thank you very much! –  Michael Stoeckli Jan 6 '13 at 17:15
add comment

2 Answers

for security its not allowable for this u can use directive add this to configuration file Order allow,deny Allow from all for more refer :http://httpd.apache.org/docs/2.2/mod/core.html#directory

share|improve this answer
add comment

For security reasons paths like ../somepath are generally not allowed when the span outside the document route. For a URL like http:/www/example.com/content/index.html they should be acceptable; but for a URL like http://www.example.com/index.html they should not.

I get requests for paths like ../../../../../etc/passwd. If this was honored, the requester would have a list of valid user ids on my system that they could try to crack.

As already noted, the error log is a good place to look for problems like this.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.