Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to restrict access to certain URLs with htpasswd files, rather than folders, is this possible? For example, I wish to restrict the URL:

But allow access to other URLs such as:

Is this possible? The "pages" part of the url refers to a pages.php file, and the "id" part is the function name in that file.

The reason for wanting to do this is because of migrating existing restrict lists, in the form of htpasswd files from another site.

Many thanks.

share|improve this question
up vote 2 down vote accepted

From the docs:

Require Directive

Description:  Selects which authenticated users can access a resource
Syntax:       Require entity-name [entity-name] ...
Context:      directory, .htaccess
Override:     AuthConfig
Status:       Core
Module:       core

"directory" context means that you can put it in <Directory>, <Location>, <Files>, and <Proxy> sections. So, yes.

share|improve this answer
Thanks very much. – me_here May 18 '10 at 14:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.