apache 虚拟主机配置
<VirtualHost *:80>
ServerAdmin xx@qq.com
DocumentRoot "/data/aaa"
ServerName www.aa.com
ServerAlias www.b.com
ErrorLog "logs/aming.com-errr.com"
CustomLog "logs/axxx" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/www/www.123.com"
ServerName www.123.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.123.com"
ServerName www.123.com
<Directory /data/wwwroot/www.123.com>
AllowOverride AuthConfig
AuthName "123 user auth"
AuthType Basic
AuthUserFile /data/.htpasswd
require valid-user
</Directory>
</VirtualHost>
apachectl -t
apachectl graceful

针对文件做限制
FilesMatch

apache实现跳转
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.123.com http://www.123.com/$1 [R=301,L]

apache查看是否加载模块
apachectl -M|grep -i rewrite
apachectl graceful
LogFormat

设置不记录图片等日志

设置缓存过期时间
ExpiresActive on
ExpiresByType image/gif "access plus 1 days"
IfModule mod_expires.c

配置防盗链

访问限制
<Directory>
Order deny,allow
Deny from all
Allow from 127.0.0.1
<Directory /ss>
<Filesmatch "admin.*">
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Filesmatch>
<Directory>
防止CC攻击和爬虫

网友评论