Can't access files in a subdirectory using Apache server
Asked Answered
K

4

5

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.

Kale answered 11/12, 2011 at 21:36 Comment(0)
K
9

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/"
Kale answered 18/9, 2013 at 14:17 Comment(1)
Same! I renamed my directory to images and it worked!Ringsmuth
O
0

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.

Overcurious answered 12/12, 2011 at 0:3 Comment(2)
Yes, Windows permissions are all the same.Kale
I tried it - no luck. httpd.conf looks like totally unresponsive to my changes. Again, subfolders like /scripts and /images are available, so I think it should be a list of them somewhere.Kale
A
0

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".

Afghanistan answered 1/6, 2012 at 22:50 Comment(0)
L
0

In Linux OS and if you use Apache, you have to change the default Apache configuration and edit this file located here

/etc/apache2/mods-available/alias.conf

In this file, you have to comment by putting # before this line

Alias /icons/ "/usr/share/apache2/icons/"

After changing the configuration, I had to restart apache

sudo service apache2 restart

And now if you check it, It should work properly.

Linsang answered 6/6, 2023 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.