Difference between revisions of "Apache HTTP Server"

From WhyAskWhy.org Wiki
Jump to: navigation, search
m (Added note re Location directive.)
m (Added sections based off of official documentation)
Line 12: Line 12:
 
== Location Directive ==
 
== Location Directive ==
  
From the official documentation <ref name="apache-2.2-core-location-directive" />:
+
''Much of the following is lifted directly from the official documentation <ref name="apache-2.2-core-location-directive" />.''
  
<blockquote>
+
=== Processing order ===
<code><Location></code> sections are processed in the order they appear in the configuration file, after the <code><Directory></code> sections and <code>.htaccess</code> files are read, and after the <code><Files></code> sections.
+
 
</blockquote>
+
* <code><Location></code> sections are processed in the order they appear in the configuration file, after the <code><Directory></code> sections and <code>.htaccess</code> files are read, and after the <code><Files></code> sections.
 +
 
 +
=== Matching rules ===
 +
 
 +
* The specified location matches exactly the path component of the URL.
 +
* The specified location, which ends in a forward slash, is a prefix of the path component of the URL (treated as a context root).
 +
* The specified location, with the addition of a trailing slash, is a prefix of the path component of the URL (also treated as a context root).
 +
 
 +
In the example below, where no trailing slash is used, requests to <code>/private1</code>, <code>/private1/</code> and <code>/private1/file.txt</code> will have the enclosed directives applied, but <code>/private1other</code> would not.
 +
 
 +
<pre>
 +
<Location /private1>
 +
    #  ...
 +
</Location>
 +
</pre>
 +
 
 +
In the example below, where a trailing slash is used, requests to <code>/private2/</code> and <code>/private2/file.txt</code> will have the enclosed directives applied, but <code>/private2</code> and <code>/private2other</code> would not.
 +
 
 +
<pre>
 +
<Location /private2/>
 +
    # ...
 +
</Location>
 +
</pre>
 +
 
 +
=== When to use <code><Location></code> ===
 +
 
 +
Use <code><Location></code> to apply directives to content that ''lives outside the filesystem''. For content that lives in the filesystem, use <code><Directory></code> and <code><Files></code>. An exception is <code><Location /></code>, which is an easy way to apply a configuration to the entire server.
  
  

Revision as of 11:20, 20 February 2015


Apache 2.2.x (and earlier?)

  • Does not support nested LDAP groups


Location Directive

Much of the following is lifted directly from the official documentation [1].

Processing order

  • <Location> sections are processed in the order they appear in the configuration file, after the <Directory> sections and .htaccess files are read, and after the <Files> sections.

Matching rules

  • The specified location matches exactly the path component of the URL.
  • The specified location, which ends in a forward slash, is a prefix of the path component of the URL (treated as a context root).
  • The specified location, with the addition of a trailing slash, is a prefix of the path component of the URL (also treated as a context root).

In the example below, where no trailing slash is used, requests to /private1, /private1/ and /private1/file.txt will have the enclosed directives applied, but /private1other would not.

<Location /private1>
    #  ...
</Location>

In the example below, where a trailing slash is used, requests to /private2/ and /private2/file.txt will have the enclosed directives applied, but /private2 and /private2other would not.

<Location /private2/>
    # ...
</Location>

When to use <Location>

Use <Location> to apply directives to content that lives outside the filesystem. For content that lives in the filesystem, use <Directory> and <Files>. An exception is <Location />, which is an easy way to apply a configuration to the entire server.


References