#
# DocumentRoot "/tmp/wangzi"
# ServerName www.yangqiding.com
#
DocumentRoot "/data/www"
ServerName www.yangqiding.com 设置主文件目录,并且定义主域名及别名和访问端口号
ServerAlias www.yanghao.com
ServerAlias www.yangteng.com
php_admin_value openn_basedir "/data/www/:/tmp/"
AllowOverride None
Options None
Order allow,deny 设置访问控制,所有的用户只能访问/data/www和/tmp/目录,只有192.168.0.114这个IP不能访问,
Allow from all
Deny from 192.168.0.114
Order Deny,Allow
Deny from all
Allow from 192.168.0.114 文件名为admin的文件拒绝所有IP访问值允许192.168.0.114和192.168.238.1这两个IP主机访问
Allow from 192.168.238.1
ErrorLog "logs/yang-error_log"
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
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/yang-access_%Y%m%d_log 86400" combined env=!image-request
ExpiresActive on
ExpiresByType image/gif "access plus 1 days"
ExpiresByType images/jpeg "access plus 24 hours"
ExpiresByType image/png "access plus 24 hours"
ExpiresByType test/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 "^http://.*\.yang\.com" local_ref
SetEnvIfNoCase Referer ".*\.yangqiding\.com" local_ref
SetEnvIfNoCase Referer "^$" local_ref
配置防盗链,是其他网站不能盗用连接来增加服务器带宽和速度
Order Deny,Allow
Allow from env=local_ref
Deny from all
php_admin_flag engine off
Order deny,allow 禁止解析php增加网站安全性,只允许本地
Deny from all
Allow from 127.0.0.1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yanghao.com$ [OR] 配置域名301跳转
RewriteCond %{HTTP_HOST} ^www.yangteng.com$
RewriteRule ^/(.*)$ http://www.yangqiding.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC]
# RewriteCond %{HTTP_USER_AGENT} ^.*chrome* [NC] 禁止user_agent
# RewriteCond %{HTTP_USER_AGENT} ^.*mozilla* [NC]
RewriteRule .* - [F]
RewriteCond %{REQUEST_URI} ^.*/tmp/.* [NC]
RewriteRule .* - [F] 通过rewrite限制某个目录的访问
AllowOverride AuthConfig
AuthName "www123com"
AuthType Basic 用户认证,访问/data/www/abc此目录需要用户名及密码
AuthUserFile /data/.htpasswd
require valid-user
# DocumentRoot "/tmp/wangzi"
# ServerName www.yangqiding.com
#
DocumentRoot "/data/www"
ServerName www.yangqiding.com 设置主文件目录,并且定义主域名及别名和访问端口号
ServerAlias www.yanghao.com
ServerAlias www.yangteng.com
php_admin_value openn_basedir "/data/www/:/tmp/"
AllowOverride None
Options None
Order allow,deny 设置访问控制,所有的用户只能访问/data/www和/tmp/目录,只有192.168.0.114这个IP不能访问,
Allow from all
Deny from 192.168.0.114
Order Deny,Allow
Deny from all
Allow from 192.168.0.114 文件名为admin的文件拒绝所有IP访问值允许192.168.0.114和192.168.238.1这两个IP主机访问
Allow from 192.168.238.1
ErrorLog "logs/yang-error_log"
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
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/yang-access_%Y%m%d_log 86400" combined env=!image-request
ExpiresActive on
ExpiresByType image/gif "access plus 1 days"
ExpiresByType images/jpeg "access plus 24 hours"
ExpiresByType image/png "access plus 24 hours"
ExpiresByType test/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 "^http://.*\.yang\.com" local_ref
SetEnvIfNoCase Referer ".*\.yangqiding\.com" local_ref
SetEnvIfNoCase Referer "^$" local_ref
配置防盗链,是其他网站不能盗用连接来增加服务器带宽和速度
Order Deny,Allow
Allow from env=local_ref
Deny from all
php_admin_flag engine off
Order deny,allow 禁止解析php增加网站安全性,只允许本地
Deny from all
Allow from 127.0.0.1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yanghao.com$ [OR] 配置域名301跳转
RewriteCond %{HTTP_HOST} ^www.yangteng.com$
RewriteRule ^/(.*)$ http://www.yangqiding.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC]
# RewriteCond %{HTTP_USER_AGENT} ^.*chrome* [NC] 禁止user_agent
# RewriteCond %{HTTP_USER_AGENT} ^.*mozilla* [NC]
RewriteRule .* - [F]
RewriteCond %{REQUEST_URI} ^.*/tmp/.* [NC]
RewriteRule .* - [F] 通过rewrite限制某个目录的访问
AllowOverride AuthConfig
AuthName "www123com"
AuthType Basic 用户认证,访问/data/www/abc此目录需要用户名及密码
AuthUserFile /data/.htpasswd
require valid-user
编辑回复