13

I've been trying to fix a weird 403 Forbidden error I get when I try to go to one of my pages via WAMP on the localhost.

After adding a rule to open up port 80 via Windows Firewall, which apache uses, I notice that this does NOT fix my problem and instead gives me a 403 forbidden for ALL my pages via localhost.

Removing the rule I just made (which caused this to begin with) does not fix it. Disabling Windows Firewall does not fix it. Restarting my computer does not fix it. Any ideas?

EDIT2: I AM able to go to localhost/phpmyadmin for whatever that's worth.

EDIT3: The contents of my httpd.conf: http://www.mediafire.com/?p54a53443efkefs

tnw
  • 13,521
  • 15
  • 70
  • 111
  • What kind of page are you trying to goto? – Anirudh Ramanathan Jun 09 '11 at 16:17
  • @anirudh: Just a basic php page that's stored in C:/wamp/www/ Every single page in my www/ folder gives me a 403 Forbidden when I try to access it via localhost/ – tnw Jun 09 '11 at 16:20
  • Is there an .htaccess file in the directory? – Sean Walsh Jun 09 '11 at 16:20
  • Are there other files that exist in the same directory? If so, can you access them? If not, move this file to a directory that you know are able to access files in. Can you access it there? – Sean Walsh Jun 09 '11 at 16:24
  • looks like a misconfiguration of your apache httpd.conf. Are you able to display the default test page? – Anirudh Ramanathan Jun 09 '11 at 16:25
  • 1
    Did you examine the error_log to check what apache had to say about this error? Give us something to work with here. – Jay Sidri Jun 09 '11 at 16:27
  • @s992: I can GET to the files and edit them just fine, just can't access them through the WAMP localhost server. – tnw Jun 09 '11 at 16:31
  • @anirudh: I can't even display that. Still a 403 Forbidden. @Jahufar: No errors appear in the Apache error log at the time that I get the 403 Forbidden errors. – tnw Jun 09 '11 at 16:33
  • why no one asking How you try to acces the page?? – zod Jun 09 '11 at 16:41
  • @Tory by "access" I meant access them via a web browser i.e. http://localhost/path/to/file.php – Sean Walsh Jun 09 '11 at 16:42
  • @s992: That wouldn't work. It would simply display the contents of the php file. If it want it to be interpreted properly and display as a php should, it needs to be in my wamp/www folder. – tnw Jun 09 '11 at 16:45
  • @Tory I am aware of this. I was under the assumption that you have multiple subfolders in your `/wamp/www/` folder. If you do, you can move your PHP file to a subfolder(`/wamp/www/trying_to_help_you/`) and then access it via http://localhost/trying_to_help_you/file.php. By finding out if this works or not, we can determine whether the issue is with a specific directory config or with your apache settings as a whole. – Sean Walsh Jun 09 '11 at 17:09
  • @s992: Ah, I misunderstood. I've tried moving the files elsewhere in www/ and it seems that every thing in www/ and all the subdirectories are forbidden. – tnw Jun 09 '11 at 17:11
  • 1
    You most likely have `deny from all` on your `` directive. Changing that to `allow from all` or `allow from 127.0.0.1` should fix the issue. I've submitted an answer as well. – Sean Walsh Jun 09 '11 at 17:16
  • @s992: replied to your answer. Checked that, reads allow from all. – tnw Jun 09 '11 at 17:23

8 Answers8

38

In httpd.conf, find the following sections and ensure they are correct:

DocumentRoot "C:/wamp/www"

<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory C:/wamp/www>
    Options None
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Those are the settings that I am using in my install and they work fine. Make sure you restart Apache if you make any changes.

If you continue having issues, please update your original question with your httpd.conf.


Edit:

This is kludgey and I'm just grasping at straws here, but try adding a new entry to your vhosts:

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
</VirtualHost>
Sean Walsh
  • 8,266
  • 3
  • 30
  • 38
  • Still a 403. My httpd.conf is linked to via mediafire in my OP. – tnw Jun 09 '11 at 17:22
  • I dropped your exact httpd.conf into my install and had no issues with it. Can you post your httpd-vhosts.conf? Try putting it up on http://pastebin.com/ instead of MediaFire. – Sean Walsh Jun 09 '11 at 17:39
  • @s992: Here ya go. http://pastebin.com/raw.php?i=j0nYBA4Q BTW, just re-installed WAMP... still a 403. – tnw Jun 09 '11 at 17:42
  • 1
    vhosts file looks fine. Edited my answer for another thing to try. Make sure you are restarting Apache after each change. – Sean Walsh Jun 09 '11 at 17:50
  • Glad that worked..I have no idea why, but for some reason I seem to remember fixing a similar problem by doing it. – Sean Walsh Jun 09 '11 at 18:06
  • 2
    Just hit this problem myself, so as a footnote to this, I installed the 64bit version of wamp and the 32 bit version on separate machines. The 32 bit version was hitting this problem but 64 bit was fine. It seems the default settings on the 64 bit version are: 'Order Allow,Deny' 'Allow from all' but the 32 bit had these as the default: 'Order Deny,Allow' 'Deny from all' 'Allow from 127.0.0.1' Copying the 64bit settings to the 32bit one worked for me. – Danny Parker Jan 30 '12 at 10:56
  • @S992 That fixed it. Amazing. I wasted 2 hours trying to figure it out. All I had to do was restart it after I made any changes to the conf files. Godlike! – Gabriel Fair Feb 19 '12 at 22:11
  • That's worked for me, this problem occurred to me when I upgraded to windows 8. Thanks – Khaled Jul 04 '12 at 10:32
  • I was accessing API (hosted in wampp server) through mobile device and I was getting the Authentication failure error.. but this solutions worked.. :) upvoted – Min2 Feb 15 '16 at 10:45
11

It can be an ipv6 issue. So in your httpd.conf add your ipv6 local address:

Change:

Allow from 127.0.0.1

to:

Allow from 127.0.0.1
Allow from ::1:
Tama
  • 181
  • 1
  • 6
  • 1
    You'd hit the bottom of problem. It occurs at Win8. Win8 seems to uses IPv6 by default and WAMP configuration is set for IPv4 by default. So it makes the conflict. – 23kulpamens Mar 21 '13 at 12:17
6

Try changing the line in httpd.conf

Allow from 127.0.0.1 

or

 Allow from all

Refer to the documentation

Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
  • 1
    Any line in my httpd.conf that has any "allow" statement is "Allow from all". – tnw Jun 09 '11 at 16:50
  • I hate to sound obtuse, but when you change httpd.conf, you are restarting Apache to let the changes take place, correct @Tory Waterman? – Mattygabe Jun 09 '11 at 17:25
  • @Matty: Definitely a mistake that happens more often than it should, but unfortunately not in this case. @anirudh: Well, if I did that, how would I know which instance of WAMP I'm running? Wouldn't any address with localhost/ be ambiguous with the other copy? – tnw Jun 09 '11 at 17:27
  • That should work, because the php test script, works perfectly on a fresh install of WAMP. – Anirudh Ramanathan Jun 09 '11 at 17:28
  • @anirudh: Re-installed. still 403. – tnw Jun 09 '11 at 17:40
  • Did you try putting the page you are trying to access in a different directory... (shot in the dark... :D) – Anirudh Ramanathan Jun 09 '11 at 17:46
  • @anirudh: yeah, i did. it seems everything including the sub-directories of www/ are ALL blocked. – tnw Jun 09 '11 at 17:50
3

Marco Tamanti solution worked for me:

Allow from 127.0.0.1
Allow from ::1:

so I have:

<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1:
</Directory>
Dave
  • 41
  • 1
  • You'd hit the bottom of problem. It occurs at Win8. Win8 seems to uses IPv6 by default and WAMP configuration is set for IPv4 by default. So it makes the conflict. – 23kulpamens Mar 21 '13 at 12:17
2

Your "Deny From All" is what's causing the 403 error. The setup you post is used to prevent all traffic, with the intention of later allowing specific traffic. If you never allow specific traffic, you'll never get it to work.

With your 404 error, ensure you're using the right path and there's no errors in your apache error log.

http://httpd.apache.org/docs/current/mod/core.html#directory

Ryre
  • 6,135
  • 5
  • 30
  • 47
  • I don't understand what I specifically need to have where in my httpd.conf. I've tried a ton of different variations, like the one in the link you mentioned, and still nothing. – tnw Jun 09 '11 at 17:05
1

you require 3 steps please ensure these 3 things

1.

first of all Port 80 and 443 must be allow for both TCP and UDP packets. To do this, create 2 inbound rules for TPC and UDP on Windows Firewall for port 80 and 443. (or you can disable your whole firewall for testing but permanent solution if allow inbound rule)

2.

If you are using WAMPServer 3 See bottom of answer

For WAMPServer versions <= 2.5

You need to change the security setting on Apache to allow access from anywhere else, so edit your httpd.conf file.

Change this section from :

#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost

To :

#   onlineoffline tag - don't remove
    Order Allow,Deny
      Allow from all

if "Allow from all" line not work for your then use "Require all granted" then it will work for you.

WAMPServer 3 has a different method

In version 3 and > of WAMPServer there is a Virtual Hosts pre defined for localhost so dont amend the httpd.conf file at all, leave it as you found it.

Using the menus, edit the httpd-vhosts.conf file.

enter image description here

It should look like this :

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Amend it to

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Hopefully you will have created a Virtual Host for your project and not be using the wamp\www folder for your site. In that case leave the localhost definition alone and make the change only to your Virtual Host.

3. Dont forget to restart All Services of Wamp or Apache after making this change

Community
  • 1
  • 1
Hassan Saeed
  • 6,326
  • 1
  • 39
  • 37
0

Simple solutions. Just Run as Administrator the Wamp Installations file and they will works like a charm :)

  • 1
    Good afternoon Elmizan - if a question is asked by a user with an established [reputation](http://stackoverflow.com/faq#reputation), it might be more appropriate to comment with this type of suggestion (unless your very confident it is the solution) rather than submit it as an answer :) – Slukehart Sep 20 '12 at 18:36
  • @Slukehart -- The post doesn't have the reputation to leave comments yet. However, since the question did have an accepted answer, I would call an additional attempt out of place. – Jeremy J Starcher Sep 21 '12 at 19:49
0

What I found worked for me after starting WAMP was, left clicking the WAMP icon that appears on the Taskbar, then clicking Start All Services under the Quick Admin. I was then able to access localhost using IE. I even went back to the httpd.config file and set it back to it's defaults.

Hope this helps.