Apache相关配置记录
时间:2015-10-07 14:10 来源:linux.it.net.cn 作者:IT
防盗链,主要根据访问来源 HTTP_REFERER 来判断是否来源本站,如果不是则返回设定的图片:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<VirtualHost 106.888.888.88:80>
ServerAdmin tom@xxxxx.com
DocumentRoot "/opt/app/php/xxxxx.img"
ServerName img.xxxxx.com
ServerAlias img.<SPAN></SPAN>xxxxx<SPAN></SPAN>.com
ErrorLog "logs/img.xxxxx.com-error.log"
CustomLog "/etc/httpd/logs/img.xxxxx.com.access.log" combined
DirectoryIndex index.php index.html index.htm
<Directory "/opt/app/php/xxxxx.img">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/opt/app/php/xxxxx.img">
<FilesMatch ".(php|asp|jsp)$">
Deny from all
</FilesMatch>
</Directory>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://xxxxx.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://xxxxx.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.xxxxx.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.xxxxx.com$ [NC] RewriteRule .*\.(gif|jpg|png|swf)$ http://www.xxxxx.com/nolink.jpg [R,NC] </VirtualHost>
301重定向,老域名转向新域名,保持域名权重:
1
2
3
4
5
6
<VirtualHost 192.168.1.12:80>
ServerAdmin tom@tom.com
ServerName toooom.com
ServerAlias www.toooom.com
RedirectMatch Permanent ^/(.*) http://www.haolianduo.com/$1 </VirtualHost>
安全配置,目录禁止执行php,exe,jsp等程序文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<VirtualHost 106.xxx.xx.xx:80>
ServerAdmin tom@tom.com
DocumentRoot "/opt/app/php/xxxxx.info"
ServerName info.xxxxx.com
ServerAlias info.xxxxx.com
ErrorLog "logs/info.xxxxx.com-error.log"
CustomLog "/etc/httpd/logs/info.xxxxx.com.access.log" combined
DirectoryIndex index.php index.html index.htm
<Directory "/opt/app/php/xxxxx.info">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/opt/app/php/xxxxx.info/uploads">
<FilesMatch ".(php|asp|jsp)$">
Deny from all
</FilesMatch>
</Directory>
<Directory "/opt/app/php/xxxxx.info/data">
<FilesMatch ".(php|asp|jsp)$">
Deny from all
</FilesMatch>
</Directory>
</VirtualHost>
(责任编辑:IT)
防盗链,主要根据访问来源 HTTP_REFERER 来判断是否来源本站,如果不是则返回设定的图片:
301重定向,老域名转向新域名,保持域名权重:
安全配置,目录禁止执行php,exe,jsp等程序文件:
(责任编辑:IT) |