Cannot access files in subdirectory using Apache server

I have an Apache 2.2.21 server installed on my Windows 7 machine. My site is up and running my scripts from the /scripts subdirectory, but when I try to load icons from /icons , I get a forbidden error 403. I 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 the files in the /icons subfolder?

PS: Using the /images subdirectory designed just fine, but the question still remains.

+4
source share
3 answers

I realized that /icons/ was included as an alias for another directory. For me, the configuration file was located at:

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

I had to comment on this line:

 Alias /icons/ "c:/Apache22/icons/" 
+2
source

Have you checked the Windows permissions in the /icons directory and made sure that the Apache user can read this directory? Perhaps there is a .htaccess file in the picture?

Edit: Good, so this is not a permission. My next guess is this: in your configuration above it says: "Everyone is denied access, except when they come from 127.0.0.1." But you are on Windows 7. Windows 7 tries to be useful and modern - and often tries to access through IPv6 in the first place. So you can appear as from :: 1, which probably does not match 127.0.0.1. Try disabling IPv6 or adding the Allow from ::1 directive.

0
source

Ok, so if your httpd.conf does nothing, you should restart apache. Any changes made to documents must be restarted so that 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 this is your code. Line 4 basically says that Apache should block all connections from connecting to the / icons / folder.

  • Also line 5 says that allow incoming connections only with 127.0.0.1 or localhost. Thus, the server has access to it!

  • If the change does not work, you should look in .htaccess. Another option is to simply copy the code from the folder that works and paste it, and simply change the paste from EX: "C: / WAMP / www / images /" to "C: / WAMP / www / icons".

0
source

Source: https://habr.com/ru/post/1385797/


All Articles