Apache服务器配置全攻略(七)_PHP
Apache
如果使用了IndexOptions FancyIndexing选项,可以让服务器产生的目录列表中针对各种不同类型的文档引用各种图标。而哪种文件使用哪种图标,则使用
下面的 AddIconByEncoding、AddIconByType以及AddIcon来定义,分别依据MIME 的编码、类型以及文件的后缀来判断使用何种图标。如果不能确定文档使用的图标,就使用 DefaultIcon定义的缺省图标。
同样,使用AddDescription可以为不同类型的文档加入不同的描述。并且,
服务器还在目录下,查询使用ReadmeName和HeaderName定义的文件(自动加上 .
html后缀,如果没有发现,再使用.txt后缀进行搜索),如果发现了这些文件,
就在文件列表之前首先显示这些文件的内容,以使得普通目录列表具备更大的可
理解性。
IndexIgnore让服务器在列出文件列表时忽略相应的文件, 这里使用模式配
置的方式定义文件名。
AddEncoding x-compress Z
AddEncoding x-gzip gz
AddEncoding用于告诉一些使用压缩的MIME类型,这样可以让浏览器进行解压缩操作。
AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it
LanguagePriority en fr de
一个HTML文档可以同时具备多个语言的版本,如对于file1.html文档可以具
备file1.html.en、file1.html.fr 等不同的版本,每个语言后缀必须使用 AddLanguage进行定义。这样服务器可以针对不同国家的客户,通过与浏览器进行协商,发送不同的语言版本。而LanguagePriority 定义不同语言的优先级,以便在浏览器没有特殊要求时,按照顺序使用不同的语言版本回应对file1.html 的请求。
这个国际化的能力实际的应用并不多。
#AddType application/x-httpd-php .phtml
#AddType application/x-httpd-php-source .phps
AddType参数可以为特定后缀的文件指定MIME类型,这里的设置将覆盖 mime.types中的设置。
#AddHandler cgi-script .cgi
AddHandler是用于指定非静态的处理类型,用于定义文档为一个非静态的文
档类型,需要进行处理,再向浏览器返回处理结果。例如上面注释中的设置是将以.cgi结尾的文件设置为cgi-script类型,那么服务器将启动这个CGI程序以进行处理。如果需要在前面AliasScript定义的路径之外执行CGI程序,就需要使用这个参数进行设置,此后以.cgi结尾的文件将被当作CGI程序执行。
在配置文件、这个目录中的.htaccess以及其上级目录的.htaccess中必须允许执行CGI程序,这需要通过Options ExecCGI参数设定。
#AddType text/html .shtml
#AddHandler server-parsed .shtml
另外一种动态进行处理的类型为server-parsed,由服务器自身预先分析网页内的标记,将标记更改为正确的HTML标识。由于server-parsed需要对text/html 类型的文档进行处理,因此首先定义了对应的.shtml为text/html类型。
然而要支持SSI,还要首先要在配置文件(或.htaccess)中使用Options Includes允许该目录下的文档可以为SSI类型,或使用Options IncludesNOExec让执行普通的SSI标志,但不执行其中引用的外部程序。
另一种指定server-parsed类型的方式为使用XBitBack设置选项,如果将 XBitHack设置为On,服务器将检查所有text/html类型的文档(包括.html后缀的文档),如果发现文件属性具备执行位 “x",则服务器就认为它是服务器分析文档,需要服务器进行处理。推荐使用AddHandler进行设置,而将XBitBack 设置为Off,因为使用XBitBack将对所有的HTML文档都执行额外的检查,降低了效率。
#AddHandler send-as-is asis
#AddHandler imap-file map
#AddHandler type-map var
上面被注释的AddHandler用于支持Apache服务器的asis、map和var处理能力
。
# Action media/type /cgi-script/location
# Action handler-name /cgi-script/location
因为Apache内部提供的处理功能有限,因此可以使用Action为服务器定义外
部程序作为可处理的动态文档类型,这些外部程序与标准CGI程序相同,都是对输入的数据处理之后,再输出不同MIME类型的结果。例如要定义一个对特殊后缀wri都先执行wri2txt进行处理操作,再返回结果的操作,可以使用:
Action windows-writer /bin/wri2txt
AddHandler windows-writer wri
更进一步,可以直接使用Action定义对某个MIME类型预先进行处理操作,这
需要例子中第一种格式的Action 参数设置方式。这样设置方式就不再需要额外的AddHandler用来将处理操作与文件后缀联系起来,而是使用Action直接处理MIME类型的文件。但如果文档后缀没有正式的MIME类型,还需要先定义一个MIME类型。
#MetaDir .web
#MetaSuffix .meta
Meta信息是在文档发送给客户之前,预先发送给客户浏览器一些数据,因此
浏览器可以通过HEAD请求来访问这些Meta信息而不必真正通过GET来返回全部文档数据。服务器通常发送给浏览器的是一些标准的HTTP头信息,如果要想增加额外的信息,就需要使用MetaDir来定义Meta数据存放的目录, 而MetaS uffix用于指定包含Meta数据的文件后缀。
#ErrorDocument 500 "The server made a boo boo.
#ErrorDocument 404 /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#ErrorDocument 402
http://some.other_server.com/subscription_info.html
如果客户请求的网页不存在,或者没有访问权限等情况发生时,服务器将产
生一个错误代码,同时也将回应客户浏览器一个标识错误的网页。
ErrorDocument就用于设置当出现哪个错误时应该回应客户浏览器那些内容,ErrorDocument的第一个参数为错误的序号,第二个参数为回应的数据,可以为简单的文本,本地网页,本地CGI程序,以及远程主机上的网页。
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4.0" force-response-1.0
BrowserMatch "Java/1.0" force-response-1.0
BrowserMatch "JDK/1.0" force-response-1.0
BrowserMatch命令为特定的客户程序,设置特殊的参数,以保证对老版本浏
览器的兼容性,并支持新浏览器的新特性。
#
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from .your_domain.com
#
#
# SetHandler server-info
# Order deny,allow
# Deny from all
# Allow from .your_domain.com
#
#
# Deny from all
# ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment
