LAMP中apache的相关配置-创新互联

关于apache的相关配置再次梳理,之前有转载他人的文章。今天把所有的实验都做了,记录一下。方便以后自己使用。

创新互联主营额尔古纳网站建设的网络公司,主营网站建设方案,成都APP应用开发,额尔古纳h5小程序开发搭建,额尔古纳网站营销推广欢迎额尔古纳等地区企业咨询
<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

##配置用户认证------begin
    <Directory /data/www/abc>
        AllowOverride AuthConfig
        AuthName "please input the password..."
        AuthType Basic
        AuthUserFile /data/.htpasswd
        require valid-user
    </Directory>
##配置用户认证------end

##配置域名跳转------begin
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.mydiscuz.com$
        RewriteRule ^/(.*)$ http://www.sunshine.com/$1 [R=301,L]
    </IfModule>
##配置域名跳转------end

##配置静态缓存------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>
##配置静态缓存------end

##关于防盗链的设置------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>
##关于防盗链的设置------end

##关于访问控制的配置------begin
    <Directory /data/www/>
        Order deny,allow
        Deny from all
        allow from all
    </Directory>
##关于访问控制的配置------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 于 北京

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

本文标题:LAMP中apache的相关配置-创新互联
网站URL:https://www.cdcxhl.com/article46/hophg.html

成都网站建设公司_创新互联,为您提供定制网站营销型网站建设手机网站建设网站建设用户体验静态网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

绵阳服务器托管