關(guān)于apache的相關(guān)配置再次梳理,之前有轉(zhuǎn)載他人的文章。今天把所有的實驗都做了,記錄一下。方便以后自己使用。

<VirtualHost *:80>
DocumentRoot "/tmp/tmp"
ServerName tmp.com
<Directory /tmp/tmp/>
Order allow,deny
Deny from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/www"
ServerName www.mydiscuz.com
ServerAlias www.sunshine.com
##配置過濾指定類型文件以及日志切割------begin
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
ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/sunshine.com-error_%Y%m%d_log 86400"
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/sunshine.com-access_%Y%m%d_log 86400" combined env=!p_w_picpath-request
##配置過濾指定類型文件以及日志切割------end
##配置用戶認(rèn)證------begin
<Directory /data/www/abc>
AllowOverride AuthConfig
AuthName "please input the password..."
AuthType Basic
AuthUserFile /data/.htpasswd
require valid-user
</Directory>
##配置用戶認(rèn)證------end
##配置域名跳轉(zhuǎn)------begin
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mydiscuz.com$
RewriteRule ^/(.*)$ http://www.sunshine.com/$1 [R=301,L]
</IfModule>
##配置域名跳轉(zhuǎn)------end
##配置靜態(tài)緩存------begin
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType p_w_picpath/gif "access plus 1 days"
ExpiresByType p_w_picpath/jped "access plus 24 hours"
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"
</IfModule>
##配置靜態(tài)緩存------end
##關(guān)于防盜鏈的設(shè)置------begin
SetEnvIfNoCase Referer "^http://.*\.sunshine\.com" local_ref
SetEnvIfNoCase Referer ".*\.sunshine\.com" local_ref
SetEnvIfNoCase Referer "^$" local_ref
<filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
Order Allow,Deny
Allow from env=local_ref
</filesmatch>
##關(guān)于防盜鏈的設(shè)置------end
##關(guān)于訪問控制的配置------begin
<Directory /data/www/>
Order deny,allow
Deny from all
allow from all
</Directory>
##關(guān)于訪問控制的配置------end
##禁止解析php的配置------begin
<Directory /data/www/data>
php_admin_flag engine off
<filesmatch "(.*)php">
Order deny,allow
Deny from all
</filesmatch>
</Directory>
##禁止解析php的配置------end
##禁止指定user_agent的配置------begin
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*Firefox.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Tomato.* [NC]
RewriteRule .* - [F]
</IfModule>
##禁止指定user_agent的配置------end
##通過rewrite限制訪問某些目錄配置------begin
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^.*/tmp/* [NC]
RewriteRule .* - [F]
</IfModule>
##通過rewrite限制訪問某些目錄配置------end
</VirtualHost>2016-03-19 21:07:47 于 北京
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
本文標(biāo)題:LAMP中apache的相關(guān)配置-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://chinadenli.net/article46/hophg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、營銷型網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、用戶體驗、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容