Why there is no <location> in my Apache2 config file?
$ sudo nano /etc/apache2/apache2.confI can find the <Directory /> as follows:
<Directory /> Options FollowSymLinks AllowOverride None Require all denied
</Directory>
<Directory /usr/share> AllowOverride None Require all granted
</Directory>
<Directory /var/www> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted
</Directory>But i cannot find at all. I am trying to allow OPTIONS DELETE PUT methods as follows:
<Location "/"> AllowMethods GET POST OPTIONS DELETE PUT Require all granted
</Location>My Apache version:
$ apache2 -v
Server version: Apache/2.4.38 (Ubuntu)
Server built: 2019-08-26T13:31:40Any ideas how to add AllowMethods GET POST OPTIONS DELETE PUT?
1 Answer
Because the <Location> directives are appropriate for specific needs (rules) and such rules are not appropriate for any default configuration :)
The
<Location>directive limits the scope of the enclosed directives by URL. It is similar to the<Directory>directive, and starts a subsection which is terminated with a</Location>directive.<Location>sections are processed in the order they appear in the configuration file, after the<Directory>sections and.htaccessfiles are read, and after the<Files>sections.
<Location>sections operate completely outside the filesystem. This has several consequences. Most importantly,<Location>directives should not be used to control access to filesystem locations. Since several different URLs may map to the same filesystem location, such access controls may by circumvented.
The <Directory /> directive refers to the root / of the filesystem. In other hand <Location /> refers to the base URI - /, where example.com is the ServerName of a virtual host. So the rules written for <Location /> will override the rules written for <Directory /var/www/html>, where /var/www/html is the DocumentRoot of the particular virtual host.