OptionsDirectives are a common and important instruction in the Apache configuration file, which Options can be used in Apache Server Core configuration (server config), virtual host configuration (VM), specific directory configuration (directory) As well as the. htaccess file used. OptionsThe primary purpose of the directive is to control which server features are enabled for a particular directory.
OptionsThe common configuration example code for directives is as follows:
- <directory />
- #指定根目录 "/" Enable indexes, followsymlinks two features.
- Options Indexes FollowSymLinks
- AllowOverride All
- Order Allow,deny
- Allow from all
- </Directory>
OptionsThe complete syntax for the directive is: Options [+|-]option [[+|-]option] ... . In short, the Options command can be appended with a specified number of server features, and feature options are separated by a space. Let's take a look at the Options specific functions and meanings of the feature options that can be appended after the instruction (the contents of the Apache configuration are not case-sensitive):
-
-
All
-
-
represents
MultiViews all attributes except the. This is also the default setting for the options directive.
-
-
None
-
-
indicates that no server attributes are enabled.
-
-
FollowSymLinks
-
-
The server allows symbolic connections to be used in this directory. If the configuration option is
<Location> in the configuration section, it will be ignored.
-
-
Indexes
-
-
If you enter a URL that corresponds to a file directory on the server, and there is no
DirectoryIndex instruction (for example:) in this directory, the DirectoryIndex index.html index.php server returns mod_autoindex a list of formatted directories generated by the module and lists all the files (such as) in that directory.
-
-
MultiViews
-
-
allows the use
mod_negotiation of modules to provide content negotiation "multi-attention graph." In short, if a client requests a path that might correspond to more than one type of file, the server will automatically select a file that best matches the client's requirements, depending on the client's request. For example, file there are two files named and in the folder under the server site, at which hello.jpg point the hello.html user enters Http://localhost/file/hello and if file there is no subdirectory under the folder hello , the server will try to file find the shape under hello.* the folder Files, and then returns the most matching requirements, depending on the specific circumstances of the user request hello.jpg hello.html .
-
-
SymLinksIfOwnerMatch
-
The
-
server uses a symbolic connection only if it has the same user ID as the owner of the destination file or directory. In short, symbolic connections are used only if the owner of the destination file or directory to which the symbolic connection and the symbolic connection points is the same user. If the configuration option is
<Location> in the configuration section, it will be ignored.
-
-
execcgi
-
-
allows the use of
mod_cgi modules to execute CGI scripts.
-
-
Includes
-
-
allows
mod_include the use of server-side include functionality provided by the module.
-
-
IncludesNOEXEC
-
-
Allow server-side containment, but disable "#exec cmd" and "#exec CGI". However, you can still
ScriptAlias use the virtual CGI script "#include virtual" from the directory.
In addition, a more attentive reader should note that the Options instruction syntax allows for the addition of the symbol "+" or "-" before the configuration option, so what does this mean?
In fact, Apache allows you to set multiple instructions in a single directory configuration Options . However, in general, if a directory is set more than once Options , one instruction that specifies the maximum number of attributes is Options fully accepted (others are ignored), and the individual Options directives are not merged. But if we precede the optional configuration with the symbol "+" or "-", it means that the optional option will be merged. All options preceded by the "+" sign will force the override of the current optional setting, and all options preceded by the "-" sign will be forced to be removed from the current optional settings. You can refer to the following example:
- #示例1
- <Directory /Web/file>
- Options Indexes followsymlinks
- </directory>
- <directory/Web/file/image>
- Options includes
- </directory>
- #目录/Web/file/image will only be set includes attribute
- #示例2
- <Directory /Web/file>
- Options Indexes followsymlinks
- </directory>
- <directory/Web/file/image>
- Options +includes -Indexes
- </directory>
- #目录/Web/file/image will be set includes,followsymlinks Two kinds of features
Note 1: mixed use of the same option preceded by "+"/"-" and without "+"/"-" may lead to unexpected results.
Note 2: -IncludesNOEXEC when used or -Includes , the server-side containment is completely disabled, regardless of the previous setting.
Apache Options Instructions