2

Before posting, I looked at:

You don't have permission to access / on this server

Application of DirectoryIndex to an Alias in Apache

As I understand it, the Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot.

Which is what I'm doing here. I have a hello.php file in C:\Users\dogzilla\PhpstormProjects\Webpage

That's not my docroot... C:\Apache\latest\www is.

When I run the project, the URL sent from the IDE to the browser is

localhost:8080/Webpage/hello.php

Which leads to a 404 error.

But I don't want to dork around with the IDE settings more than I have so I added this to my httpd.conf. I only grabbed "Webpage" because that's all which was in the URL when the 404 error was displayed.

Alias /Webpage C:/Users/dogzilla/PhpstormProjects/Webpage

When I re-ran my project, the 404 went away but the 403 error appeared.

So, in reading those two links above, I added this to httpd.conf too:

<Directory "C:/Users/dogzilla/PhpstormProjects/Webpage">
  Order allow,deny
  Allow from all
</Directory>

(Yeah, I'll tighten up security once this is running)

But I still get the 403 errors.

What am I doing wrong? I've tried to RTFM. Clearly I'm still doing something wrong.

MGoBlue93
  • 644
  • 2
  • 14
  • 31
  • @CBroe Why do I "have" to do that? Apache aliases are set up for EXACTLY the reason why I'm posting here in the first place. – MGoBlue93 Oct 19 '17 at 21:38
  • You should add `Options Indexes` to your directory permisions so in case your server doesn´t find the default files (index.html, index.php......), server return your directory. In case ` Options Indexes` is not implemented server return `403 Forbiden` - **You can see my full answers below** – Iker Solozabal Feb 13 '21 at 11:02

2 Answers2

5

If you are creating an Alias to a directory outside of your DocumentRoot, you may need to explicitly permit access to the target directory.

Alias "/image" "/ftp/pub/image"
<Directory "/ftp/pub/image">
    Require all granted
    Options Indexes
</Directory>

If Options Indexes is not set, and no default files are find, server return a 403 status code and will not show your directory.

Default files server will try to open are found in httdd.conf

<IfModule dir_module>
        DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                       default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                       home.php home.pl home.cgi home.asp home.shtml home.html home.htm
    </IfModule>
Iker Solozabal
  • 1,232
  • 11
  • 16
0

I think I found the answer... I was using 2.2 conf commands rather than 2.4. These links shed the light. With the changes in httpd.conf between 2.2 and 2.4, I guess the moral of the story is to pay attention to the details:

https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration

Forbidden You don't have permission to access / on this server

MGoBlue93
  • 644
  • 2
  • 14
  • 31
  • 1
    Just for anyone else that comes along, in my case I had the Apache directives correct, but there was an `.htaccess` file blocking access. – The Unknown Dev Nov 13 '18 at 20:28