//Apache website configuration file/usr/local/apache2/conf/extra/httpd-vhosts.conf-before you edit this file, you need to go to httpd.conf to remove the comment from the file.<virtualhost *: the>DocumentRoot"/data/www"ServerName www.123. com #不记录指定文件的日志-- also add env setenvif Request_uri". *\.gif$"image-Request Setenvif Request_uri". *\.jpg$"image-Request Setenvif Request_uri". *\.png$"image-Request Setenvif Request_uri". *\.bmp$"image-Request Setenvif Request_uri". *\.swf$"image-Request Setenvif Request_uri". *\.js$"image-Request Setenvif Request_uri". *\.css$"image-request#日志设置errorlog"|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/aaa-error_%y%m%d.log 86400"Customlog"|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/aaa-access_%y%m%d.log 86400"Combined env=!image-request#301跳转<ifmodule mod_rewrite.c>rewriteengine on #进入下列网站 rewritecond%{http_host} ^www.tiaozhuan.com [OR] Rewritecond%{http_host} ^www.test.com$ #都跳转到www.123. com rewriterule^/(. *) $ http://www.123.com/$1 [r=301,l]#禁止user_agent NC is case-insensitive or represents either of the two or rule- F All Access denied Rewritecond% (Http_user_agent} ^mozilla/5.*[NC] Rewritecond% (Http_user_agent} ^.*chrome*[NC] rewriterule.* -[F]#限制某一个目录不让用户访问, you can also use Deny and allow to limit Rewritecond%{request_uri} ^.*/tmp/.*[NC] rewriterule.* -[F]</IfModule> #静态缓存#1. MOD_EXPIRES.C<ifmodule mod_expires.c>expiresactive on Expiresbytype image/gif"Access plus 1 days"Expiresbytype Image/jpeg"Access plus hours"Expiresbytype Image/png"Access plus hours"Expiresbytype Text/css"Now plus 2 hours"Expiresbytype Application/x-javacript"Now plus 2 hours"Expiresbytype Application/javascript"Now plus 2 hours"Expiresbytype Application/x-shockwave-flash"Now plus 2 hours"ExpiresDefault"Now plus 2 hours"</IfModule>#访问控制<Directory/data/www/>Order Deny,allow deny from all allow from 127.0.0.1</Directory> #针对请求的URI限制#<filesmatch"(. *) admin (. * )"># Order deny,allow# deny fromall# Allow from 127.0.0.1# </filesmatch> #全部PASS#<Directory>#Order deny,allow#全部NOT PASS#<Directory>#Order allow,deny#针对网站的用户上传的文件进行限制php解析<Directory/data/www/data>Php_admin_flag engine off<filesmatch"(. *) PHP">Order Deny,allow deny from all allow from 127.0.0.1</filesmatch></Directory> #防盗链setenvifnocase Referer"^htt://.*\baidu\.com"local_ref setenvifnocase Referer"^htt://.*\sohu\.com"local_ref setenvifnocase Referer"^$""Local_ref<filesmatch"\. (txt|doc|mp3|zip|rar|jpg|gif|png)">Order Allow,deny allow fromenv=Local_ref</filesmatch></VirtualHost>#2 . Mod_headers#<ifmodule mod_headers.c>#htm, the file cache for the Html,txt class is stored for one hours #<filematch"\. (htmlhtm|txt) $">#headerSetCache-control"max-age=3600" # </filematch>
Errors encountered in writing the configuration file:
1.
/usr/local/apache2/bin/apachectl-t
Syntax error on line of/usr/local/apache2/conf/extra/httpd-vhosts.conf:
AuthUserFile takes 1-2 arguments, text file containing user IDs and passwords
1. Because of the extra allowoverride authconfig
2.34 lines have Chinese comments, delete them
Apache various configurations