Control web page access

On this page:


You can control who is able to view your web pages by using .htaccess files in your www or wwws directories and subdirectories. When using .htaccess controls that require IU Network ID authentication, you must use the Secure WWW server.

By adding an Error Document Directive to your .htaccess file, you can provide custom error messages so that users can contact you in case of problems.

When a user tries to access one of your web pages, the web server looks for a .htaccess file in the directory where the file is stored. If there is a .htaccess file present, the user must meet the authentication requirements defined in the file in order to view the page. If there is no .htaccess file present, the web page will be displayed.

If there is a problem with the way the .htaccess file is written, an Internal Server Error page will be displayed.

Use IU Network ID authentication with a virtual host address

With a virtual host, if you choose to restrict access in a way that requires IU Network ID authentication as described in this document, you must store the web content on the secure server (wwws directory). Doing so will require an additional virtual host configuration on the server. To request this additonal configuration, contact Web Services Support. Requests may take up to three business days for processing.

Allow all IU users

If you wish to restrict access to anyone who has an IU Network ID/passphrase, you may do so by using a predefined access control option available on Webserve. For security reasons, you must use this in the wwws directory within your account.

To activate this option, log into your account on Webserve and move to the wwws directory. (To restrict access to only certain subdirectories, move to the directory you wish to restrict.) Type the following command:


Any person with an IU Network ID will be able to authenticate; others will receive a "403 Forbidden" error message.

Restrict to specific IU users

For security reasons, you may use this only in the wwws directory within your account.

To restrict access to certain IU Network IDs, create or modify a .htaccess file to look something like this:

AuthGroupFile /dev/null
AuthType CAS
AuthName "IU Network ID"
<Limit GET POST>
require user greg peter bobby sam oliver

The "AuthType" field is defined as CAS, so website visitors will be directed to the familiar CAS login screen, and must use their IU Network usernames and passphrases to authenticate. The require user directive within the Limit tags lists the IU Network usernames allowed to access the files in this directory. In this case, the network usernames greg, peter, bobby, sam, and oliver are permitted access. Everyone else will receive an error message if they try to log in.

If your list of required users is long, make sure there are no line breaks in the list of names. If your list exceeds the number of characters that can be contained in one line, your users may receive an "Internal Server Error" message instead of a login box. The solution is to separate your list of users into several require user statements, as shown:

<Limit GET POST> 
require user greg peter bobby sam oliver james ebenezer harold scott robert 
require user kate elizabeth sarah jennifer alison susan megan erica leslie

With this type of authentication, users log in with their network usernames and passphrases, so you don't have to maintain passwords for them.

Restrict to specific ADS groups

The following shows how to use LDAP in the .htaccess file to restrict access based on ADS groups. This method also uses the familiar CAS login to initially authenticate the user. For security reasons, you may use this only in the wwws directory within your account.

Put the following in your .htaccess file:

AuthType CAS
AuthName "LOGIN"
AuthUserFile /dev/null
AuthzLDAPAuthoritative off
AuthLDAPURL "ldap://,dc=ads,dc=iu,dc=edu?cn"
AuthLDAPBindDN "cn=<user to bind to ldap>,ou=accounts,dc=ads,dc=iu,dc=edu"
AuthLDAPBindPassword "exec:<path to password script>"

#To restrict based on group membership:
Require ldap-group <ldap-group path>

#To restrict based on user:
Require ldap-user <ldap user>
  • <ldap-group path> is the full Distinguished Name of the LDAP group. For example, the group of all UITS employees would be:
  • For the <user to bind to ldap>, UITS strongly recommends that you request a separate group account that will only be used for this purpose. Do not use a personal account for this purpose.

In order to prevent your LDAP account password from being visible to other Webserve users, do the following:

  1. Create a directory in the home directory of your Webserve account and set the permissions as follows:
    mkdir /ip/<username>/.ldap
    chmod 6711 .ldap

    The directory permissions should look like this:

    drws--s--x    2 <account> ip       2048 Jul 26 09:47 .ldap
  2. Create a script in this directory with the following code. For purposes of this example, we'll call it
    echo "<ldap_password>"
  3. Set the following permissions on your password script:
    chmod 715

    The file permissions should look like this:

    -rwx--xr-x 1 <username> ip 37 Jul 26 09:47
  4. In this example, the relevant line in the .htaccess file would look like:
    AuthLDAPBindPassword "exec:/ip/<username>/.ldap/"

This is document bfro in the Knowledge Base.
Last modified on 2019-03-20 14:53:02.

Contact us

For help or to comment, email the UITS Support Center.