Reputation: 830
Im not that familiar with Apache.
<Location>
, I am able to redirect users to a sign-on page, forcing them to authenticate and have proper privileges before accessing the URL.<Directory>
, it is supposed to allow me to control access to specified folders and directories, right?Question:
How does <Directory>
behave similarly and differently from <Location>
?
<Location /web>
: www.mysite.com/web and www.mysite.com/web/foo will be controlled.<Directory /webforms>
: how will www.mysite.com/web look like if some of the scripts are from that folder?<Directory /pictures>
: how will www.mysite.com/web look like if some of the picture are from that folder?Upvotes: 12
Views: 20136
Reputation: 62635
The Apache HTTP server documentation has a section called What to use When which, I think, directly answer your question :
Choosing between filesystem containers and webspace containers is actually quite easy. When applying directives to objects that reside in the filesystem always use
<Directory>
or<Files>
. When applying directives to objects that do not reside in the filesystem (such as a webpage generated from a database), use<Location>
.
The important part is the following :
It is important to never use
<Location>
when trying to restrict access to objects in the filesystem. This is because many different webspace locations (URLs) could map to the same filesystem location, allowing your restrictions to be circumvented.
Read on for more information...
Upvotes: 13