Apache Configure user authentication domain name jump log static cache file anti-theft link

Source: Internet
Author: User

Configuration file:/usr/local/apache2/conf/extra/httpd-vhosts.conf

<virtualhost *:80>

ServerAdmin [email protected]

DocumentRoot "/data/www"

ServerName www.1.com

Serveralias www.a.com www.b.com

#配置用户认证

<Directory/data/www>

allowoverride authconfig

AuthName "132"

authtype Basic

authuserfile/data/.htpasswd

require Valid-user

</Directory>

#配置域名跳转

<ifmodule mod_rewrite.c>

Rewriteengine on

Rewritecond%{http_host} ^www.a.com$ [OR]

Rewritecond%{http_host} ^www.b.com$

Rewriterule ^/(. *) $ http://www.1.com/$1 [r=301,l]

</IfModule>

#配置日志

Errorlog "/usr/local/apache2/logs/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/1.com-access_%y%m%d.log 86400" combined env =!image-request

#配置静态文件缓存

<ifmodule mod_expires.c>

Expiresactive on

Expiresbytype image/gif "Access plus 1 days"

Expiresbytype image/jpeg "Access plus hours"

Expiresbytype image/png "Access plus 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"

</IfModule>

#配置防盗链接

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

<filesmatch "\. (txt|doc|mp3|zip|rar|jpg|gif) ">

Order Allow,deny

Allow from Env=local_ref

</filesmatch>

</VirtualHost>


This article is from the "david0512" blog, make sure to keep this source http://gjr0512.blog.51cto.com/6518687/1651913

Apache Configure user authentication domain name jump log static cache file anti-theft link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.