Can't access files in a subdirectory using Apache server

送分小仙女□ 提交于 2019-12-07 07:30:48

问题


I have an Apache 2.2.21 server installed on my Windows 7 machine. My site is up and my scripts from /scripts subdirectory are working but when I try to load icons from /icons I get a 403 forbidden error. I've already added this to my httpd.conf file:

<Directory "c:/wamp/www/icons/">
    Options Indexes FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

Still no effect. So the question is: how can I access files in my /icons subfolder?

P.S.: Using /images subdirectory worked out just fine but the question still remains.


回答1:


I figured out that /icons/ was included as an alias for some other directory. For me, configuration file was located at:

C:\wamp\bin\apache\apache2.2.21\conf\extra\httpd-autoindex.conf

I had to comment out this line:

Alias /icons/ "c:/Apache22/icons/"



回答2:


Have you checked the Windows permissions on the /icons directory, and made sure that the Apache user can read that directory? Is there possibly an .htaccess file in the picture?

Edit: Okay, so it's not permissions. My next guess is this: your config above says "everyone is forbidden access except when they're coming from 127.0.0.1". But you're on Windows 7. Windows 7 tries to be helpful and modern - and often tries accessing via IPv6 first. So you might show up as coming from ::1, which is probably failing to match 127.0.0.1. Try turning off IPv6 or adding an Allow from ::1 directive.




回答3:


Ok so if your httpd.conf doesn't do anyhting you should restart apache. Any changes done to documents have to be restarted so Apache can "Refresh".

<Directory "c:/wamp/www/icons/">
     Options Indexes FollowSymLinks
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
</Directory>
  • So above this is your code. It basically says in line 4 that Apache should deny connection from all incoming connections connections to the /icons/folder.

  • Also on line 5 it says to allow incoming connections from only 127.0.0.1 or localhost. So basically the server has access to it!

  • If changing it doesn't work you should look in .htaccess. Another option is just to copy the Code from a folder that works and paste it and just change the paste from EX: "C:/WAMP/www/images/" to "C:/WAMP/www/icons".



来源:https://stackoverflow.com/questions/8467690/cant-access-files-in-a-subdirectory-using-apache-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!