Alias 403 Forbidden with Apache

58,361

Solution 1

If you're using apache 2.4

Order allow,deny
Allow from all

becomes...

Require all granted

https://httpd.apache.org/docs/2.4/upgrading.html

Solution 2

I know it's old but just for the record, the following worked for me in XAMPP (Windows 8)

Alias /projects c:/projects

<Directory c:/projects>
    Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    Allow from all
</Directory>

EDIT

On XAMPP 5.6 and Apache 2.4 try this:

Alias /projects c:/projects

<Directory c:/projects >
    Options Indexes FollowSymLinks MultiViews
    Require all granted
</Directory>

Solution 3

I fixed this issue with these directives:

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local

You'll only be able to browse from your local computer, but it works for local testing and development.

Solution 4

Trying the solutions offered by the other answers here, and finding they didn't work for me, using Linux Mint, I found another option to start apache as a different user.

After reading unixd_module documentation, I edited "httpd.conf" to change the User and Group to that of the owner of the Alias directory (or root user) and the 403 "Forbidden" error had gone.

  1. Open your "httpd.conf" at /opt/lampp/etc/httpd.conf (in a default installation of XAMPP for example) in a text editor.

  2. Find <IfModule unixd_module>, where the comments should read something like:

    If you wish httpd to run as a different user or group, you must run httpd as root initially and it will switch.

    User/Group: The name (or #number) of the user/group to run httpd as.

    It is usually good practice to create a dedicated user and group for running httpd, as with most system services.

    with the default User and Group set to daemon.

  3. Edit the User and Group.

For example:

<IfModule unixd_module>
  User mrJohn
  Group mrJohn
</IfModule>

I hope this is useful.

Solution 5

For me worked this solution:

When I access the virtual directory an error “Access forbidden! Error 403” occured.
The config seems to ok:

Alias /static/ /home/username/sites/myblog/static/
<Directory /home/username/sites/myblog/static> Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny Allow from all </Directory>
Solution: The default apache configration is very restrictive. It do not allow to access directories without authentication. This is defined in the Directory section of httpd.conf: <Directory> AllowOverride none Require all denied </Directory>
Add a “require all granted” directive to your virtual directory section will grant the access.

Alias /static/ /home/username/sites/myblog/static/ <Directory /home/username/sites/myblog/static> AllowOverride All Order allow,deny Allow from all Require all granted </Directory>

Share:
58,361
Yousif
Author by

Yousif

Updated on August 03, 2020

Comments

  • Yousif
    Yousif almost 4 years

    I'm trying to create a folder named week7 and an html page named hello.html in that folder outside the document root and have it viewed through an Alias directive.

    I created a folder named week7 out of the Document Root. I chose this location for it:

    /usr/local/www/week7
    

    while my document root is:

    /usr/local/www/apache22/data
    

    in httpd.conf and under tag, I wrote:

        Alias /week7 /usr/local/www/week7
    <Directory /usr/local/www/week7>
        Require all granted
    </Directory>
    

    After rebooting the server, I got the following message: Forbidden 403 message.

    I tried changing permissions for the hello.html file, the week7 folder and even the www folder and nothing changed.

    Any ideas?