2

I have an Apache config that restricts access to to a website, using the following code -

<Directory /var/www/html/website/test/>
        AuthName "Dyne Drewett Test Site"
        AuthType Basic
        AuthUserFile /usr/local/etc/apache/.htpasswd
        require valid-user
</Directory>

Does anybody know how I can amend this to allow full, unauthorised access to one directory under /test/? Thanks.

Update

After some help from @dunxd I now have this, which I'm guessing must be wrong as I'm still getting the 401 error when going to the page that is requested (found with the /dyne_drewett/ directory). Any further help would be great.

# Main directory rules
<Directory /var/www/html/website/test/>

    # General access to the site
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from 192.168.1

    # Authorisation settings
        AuthName "Dyne Drewett Test Site"
        AuthType Basic
        AuthUserFile /usr/local/etc/apache/.htpasswd
        require valid-user

</Directory>

# Theme directory rules
<Directory /var/www/html/website/test/wp-content/themes/dyne_drewett/>

    # General access to the folder
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all

    # Authorisation settings
        AuthType None
        require all granted

</Directory>

1 Answer 1

5

There are a couple of ways of achieving this.

Simplest way is to create another Directory entry for the subdirectory with AuthType set to None like this:

<Directory /test/public>
AuthType None
Require all granted
</Directory>

Another approach uses a different URL pointing to the directory. In Apache docs for Directory directive there is a comment saying:

Be careful with the directory-path arguments: They have to literally match the filesystem path which Apache httpd uses to access the files. Directives applied to a particular will not apply to files accessed from that same directory via a different path, such as via different symbolic links.

You could use that to your advantage here - create a symlink from /allowed/ to your subdirectory under /test/ and use that URL to point to the directory.

2
  • Thanks for the help. I've updated my question with all <directory> entries from my config, as I still can't get it to work. I'd be grateful if you could take a look and let me know if anything looks incorrect. Thanks.
    – David Gard
    Mar 13, 2012 at 15:41
  • @DavidGard I'm not sure why your <directory> rules aren't working. I copied your rules and they worked for me. The difference I have is that I don't have a slash at the end of the directory path
    – icc97
    Jul 8, 2015 at 11:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .