Apache's http service

1. <IfModule Directory Module>
  <IfModule Directory Module> acting on the module, it first determines whether the load module, and then decide whether to process, that is to say only when the determination result is executed instructions within the container will be true Instead if false, it will all be ignored. May be used <IfModule module name> or <IfModule! Module name> module determines whether the load.
Example 1:
In this example, <IfModule> dir_module determines whether loading, DirectoryIndex index.html loaded if the instruction is executed.
Here Insert Picture Description
Example 2:

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
	User daemon
	Group daemon
< /IfModule>
< /IfModule>

In the example above, <IfModule> containers will be loaded first determines whether mpm_netware_module module, if not loaded, would proceed to the next container, it is determined whether the loaded module mpm_winnt_module, when there is no load mpm_winnt_module, <IfModule> user and group instruction is executed in the container.
2. <IfDefine> container

<IfDefine> container <IfModule> similar containers, all of the conditions to judge, but <IfDefine> container will be performed only if the condition is true, but it also need to add specific parameters in order to play at the start httpd effect.

< IfDefine  Proxy>
	LoadModule  proxy_module  modules/libproxy.so
< /IfDefine>

To the above command is to take effect at the start httpd statement should look like this:
httpd -D Proxy

<IfDefine !Proxy>
	LoadModule proxy_module  modules/libproxy.so
</IfDefine>

httpd -D Proxy

In this example, <IfDefine! Proxy> container! Proxy compared with the previous more than a "!", So it is completely contrary to the previous example, <IfDefine! Proxy> Settings in the container will be ignored.

  1. <Directory> and <DirectoryMatch> container

<Directory> container of the role is to make it work instruction package in the specified directory and its subdirectories, the directory must be a complete path, of course, you can use wildcard "*", "?" Matches directory, You can also use "[]" to determine the character range, but whether it is "*", "?", or "[]" can not match "/"
for example, <Directory / srv / * /html/index.html > can not match <Directory / srv / * /index.html> , and the only match <Directory /srv/apache/html/index.html> or <Directory /srv/username/html/index.html>.

<Directory /srv/apache/html/>
	Order Deny,Allow	
	Deny from All
</Directory>

In the above example, banned access to the / srv / apache / html / directory, any request to the / srv / apache / html / links will be rejected.

In addition to the above-mentioned and wildcard "[]", also by adding the preceding regular expression "~" to use regular expression matching, for example:

<Directory  ~"^/srv/apache[0-9]{2}/html/">
	Order Deny,Allow
	Allow from All
</Directory>

In the above example, by the use of regular expressions to match the two-digit number beginning with all apache to 0-9 at the end of the directory / srv / / html / directory and the directories allow access by any user, the container URL request is similar to the following links:

<DirectoryMatch> similar effects container <Directory> container, are applied to the directory, but <DirectoryMatch> container can be accepted regular expressions, without adding "~", for example:

<DirectoryMatch "^/srv/apache[0-9]{2}/html/">
	Order Deny,Allow
	Allow from All
</DirectoryMatch>
  1. <Files> and <FilesMatch> container

And <Directory> acting on the container corresponding to the directory, <Files> act only on the container document, and <Directory> containers, with a wildcard and the "[]" in the front and adding positive expression "~" to use regular expression matching files. For example, at the end of the match all the .html file with the extension and allow all users access to:

<Files "^\.html">
	Order Deny,Allow
	Allow from All
</Files>

<FilesMatch> container <Files> like containers, but in addition to its <Files> container's function, but also can be used as a regular expression matching.

Published 17 original articles · won praise 2 · Views 368

Guess you like

Origin blog.csdn.net/qq_44487069/article/details/104539918