vhost配置
DocumentRoot "/tmp/tmp"
ServerName tmp.com
Order allow,deny
Deny from all
DocumentRoot "/data/www"
ServerName www.1.com
ServerAlias www.a.com www.b.com
ServerAlias www.c.com
# 用户认证
#
# AllowOverride AuthConfig
# AuthName "alksdjflkasjdf"
# AuthType Basic
# AuthUserFile /data/.htpasswd
# require valid-user
#
# 域名跳转
RewriteEngine on
# RewriteCond %{HTTP_HOST} ^www.a.com$ [OR]
RewriteCond %{HTTP_HOST} !^www.1.com$
RewriteRule ^/(.*)$ http://www.1.com/$1 [R=301,L]
RewriteRule ^/(.*)\.png$ /static/p_w_picpath/common/fav.gif [R=302]
#RewriteRule ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page%3D$2
RewriteRule ^/topic-(.+)\.html$ /portal.php?mod=topic&topic=$1&%1
RewriteRule ^/article-([0-9]+)-([0-9]+)\.html$ /portal.php?mod=view&aid=$1&page=$2&%1
RewriteRule ^/forum-(\w+)-([0-9]+)\.html$ /forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteRule ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteRule ^/group-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=group&fid=$1&page=$2&%1
RewriteRule ^/space-(username|uid)-(.+)\.html$ /home.php?mod=space&$1=$2&%1
RewriteRule ^/blog-([0-9]+)-([0-9]+)\.html$ /home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteRule ^/archiver/(fid|tid)-([0-9]+)\.html$ /archiver/index.php?action=$1&value=$2&%1
RewriteRule ^/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ /plugin.php?id=$1:$2&%1
RewriteCond %{HTTP_USER_AGENT} ^.*Firefox/4.0* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*curl* [NC]
RewriteRule .* - [F]
# 配置日志
ErrorLog "/usr/local/apache2/logs/dummy-host.example.com-error_log"
SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request
SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request
SetEnvIf Request_URI ".*\.png$" p_w_picpath-request
SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request
SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request
SetEnvIf Request_URI ".*\.js$" p_w_picpath-request
SetEnvIf Request_URI ".*\.css$" p_w_picpath-request
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/1.com-access__%Y%m%d.log 86400" combined env=!p_w_picpath-request
# 配置静态文件缓存
#
# ExpiresActive on
# ExpiresByType p_w_picpath/gif "access plus 1 days"
# ExpiresByType p_w_picpath/jpeg "access plus 24 hours"
# ExpiresByType p_w_picpath/png "access plus 24 hours"
# ExpiresByType text/css "now plus 2 hour"
# ExpiresByType application/x-javascript "now plus 2 hours"
# ExpiresByType application/javascript "now plus 2 hours"
# ExpiresByType application/x-shockwave-flash "now plus 2 hours"
# ExpiresDefault "now plus 0 min"
#
header set cache-control "max-age=3600"
header set cache-control "max-age=604800"
header set cache-control "max-age=29030400"
# 配置防盗链
SetEnvIfNoCase Referer "^http://www.1.com" local_ref
SetEnvIfNoCase Referer "www.a.com" local_ref
SetEnvIfNoCase Referer "www.b.com" local_ref
SetEnvIfNoCase Referer "^$" local_ref
Order Allow,Deny
Allow from env=local_ref
# 访问控制
#
#
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
#
#
#
#
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
#
#
php_admin_flag engine off
Order deny,allow
Deny from all
######################################
#虚拟主机配置
DocumentRoot "/data/www"
ServerName www.dis1.com
ServerAlias www.dis2.com
ErrorLog "logs/dis1.com-error_log"
#访问日志不记录指定类型的文件
SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request
SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request
SetEnvIf Request_URI ".*\.png$" p_w_picpath-request
SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request
SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request
SetEnvIf Request_URI ".*\.js$" p_w_picpath-request
SetEnvIf Request_URI ".*\.css$" p_w_picpath-request
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/dis1.com-access_log_%Y%m%d 86400" combined Env=!p_w_picpath-request
#域名跳转
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.dis2.com$
RewriteRule ^/(.*)$ http://www.dis1.com/$1 [R=301,L]
#通过rewrite模块限制指定的User_Agent访问
RewriteCond %{HTTP_USER_AGENT} ^.*sogou.* [NC]
RewriteRule .* - [F]
#通过rewrite模块限制对/data/www/tmp目录的访问
RewriteCond %{REQUEST_URI} ^.*/tmp/.* [NC]
RewriteRule .* - [F]
#指定文件静态缓存
ExpiresActive on
ExpiresByType p_w_picpath/gif "access plus 1 days"
ExpiresByType p_w_picpath/jpg "acccess plus 24 houre"
ExpiresByType p_w_picpath/png "access plus 24 hours"
ExpiresByType text/css "now plus 2 hours"
ExpiresByType application/x-javascript "now plus 2 hours"
ExpiresByType application/x-shockwave-flash "now plus 2 hours"
ExpiresDefault "now plus 0 min"
#防盗链
SetEnvIfNoCase Referer ".*\.dis1.com" local_ref
Order Allow,Deny
Allow from env=local_ref
#Apache访问控制
AllowOverride None
Options None
Order Allow,Deny
Allow from all
Deny from 127.0.0.1
#限制某些页面只能从固定ip访问
Order Deny,Allow
Deny from all
Allow from 192.168.31.184
#禁止解析并下载php文件,假如.php文件放在/data/www/data下
php_admin_flag engine off
Order Deny,Allow
Deny from all
#指定目录用户认证
AllowOverride AuthConfig
AuthName "Need to be allowed!"
AuthType basic
AuthUserFile /data/.htpasswd
Require valid-user