43

I have Zend Server installed and noticed something like the following was added to my httpd.conf file:

<Location /ZendServer>
 Order Allow,Deny
 Allow from 127.0.0.1
</Location>

Alias /ZendServer "C:\Program Files\Zend\ZendServer\GUI\html"

<Directory "C:\Program Files\Zend\ZendServer\GUI\html">
 AllowOverride All
</Directory>

But I can't seem to understand the difference between Location and Directory. I changed to something like the following, which makes more sense to me, and it still works:

<Location /ZendServer>
 AllowOverride All
 Order Allow,Deny
 Allow from 127.0.0.1
</Location>

Alias /ZendServer "C:\Program Files\Zend\ZendServer\GUI\html"

Can I keep my changes or should I put it back the way it was?

rfgamaral
  • 940
  • 2
  • 11
  • 18

2 Answers2

55

Directory directive works only for filesystem objects (e.g. /var/www/mypage, C:\www\mypage), while Location directive works only for URLs (the part after your site domain name, e.g. www.mypage.com/mylocation).

The usage is straightforward - you would use Location if you need to fine tune access rights by an URL, and you would use Directory if you need to control access rights to a directory (and its subdirectories) in the filesystem.

ipozgaj
  • 1,061
  • 10
  • 10
  • I'm still confused... Why did Zend used both then? Can I keep my changes or is something wrong with that? – rfgamaral Nov 01 '10 at 16:51
  • 1
    No, your configuration is not the same as the original one - you removed AllowOverride from Directory directive, and that means you won't be able to use .htaccess file in C:\Program Files\Zend\ZendServer\GUI\html directory. Directory options setup are different from URL options setup, that's why they used both of them. – ipozgaj Nov 01 '10 at 17:13
  • 1
    Long writeup in the apache docs about Directory vs. Location (and others): http://httpd.apache.org/docs/2.2/sections.html – Dan Pritts Apr 09 '15 at 18:19
2

Location can be used when using an AJP or proxy redirect. For example, Oracle's PLSQL APEX module uses the following URL: /pls/apex/f?p=1:1

If you try to restrict this using directory, it will never work since it's a pass-thru and not a physical directory on the server. Location works!