|
Limit access to certain computersLast revision July 20, 2004 Make your .htaccess file with the lines specified below, but substituting values that are appropriate to your case wherever you see italicized keywords.
AuthType Basic The Order directive line just says that when the web server is checking to see whether to allow access to a viewer on a particular computer, it will first check to see if any Deny directives apply, and then look to see if any Allow directives apply. The next line, the Deny from all directive, then says the basic default condition is to not let any computer have access. This default denial can then be overridden by giving permission to specific computers. You can now put in one or more Allow from directives to allow access by specific computers. You can specify either a single IP address, a range of IP addresses, a single complete host name, or a domain of hostnames. You can have multiple Allow from directives to mix and match among these formats. Here are examples of various Allow from directives showing how to limit access with the different formats. Allow from 171.64.168.69
Allow from 171.64.168.0/21
Allow from gondwana.stanford.edu Allow from stanford.edu For a complete example, suppose the pangea user with account name "joe" wants to put some html files in his personal web directory and limit access to only computers at Stanford. His personal web directory is the subdirectory WWW in his home directory. He is in the Geological and Environmental Sciences department, so the full Unix directory path of this directory on pangea is /home/ges/joe/WWW. The web URL for this directory is simply http://pangea.stanford.edu/~joe. Joe makes a sub-directory within WWW to store his restricted files, and calls that sub-directory personal. Its complete Unix path is /home/ges/joe/WWW/personal, and its URL is http://pangea.stanford.edu/~joe/personal/. Within that personal directory, Joe makes the file .htaccess with the following lines: AuthType Basic
|