apache rewrite 讲解
分类:威尼斯手机平台

Apache Rewrite实例2007-03-04 11:25VirtualHost *:80 ServerAdmin host@discuz.com DocumentRoot D:/www ServerName ServerAlias xiaojia.com xiaojia.net ErrorLog D:/_log CustomLog D:/_log%Y%m%d combined# Alias /upimg /home/# Alias /wiki /home/ IfModule mod_rewrite.c RewriteEngine On# RewriteCond %{HTTP_HOST} !111cn.net [OR]# RewriteCond %{HTTP_HOST} !# RewriteRule ^(.*)$ $1 [R=301,L] RewriteRule ^(.*)/archiver/([a-z0-9/-]+/.html)$ $1/archiver/index.php?$2 RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)/.html$ $1/forumdisplay.php?fid=$2page=$3 RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)/.html$ $1/viewthread.php?tid=$2extra=page/%3D$4page=$3 RewriteRule ^(.*)/profile-(username|uid)-(.+)/.html$ $1/viewpro.php?$2=$3 /IfModule/VirtualHost

  1. 下载discuz!
    mkdir /data/www
    cd /data/www
    wget 
    unzip Discuz_X3.2_SC_GBK.zip
    mv upload/*  .
  2. 安排第一个设想主机
    删除httpd.conf中的那行前面包车型客车警示信号
    #Include conf/extra/httpd-vhosts.conf
    vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
    加盟如下配置:
    <VirtualHost *:80>
        DocumentRoot "/data/www"
        ServerName www.123.com
    </VirtualHost>
  3. 安顿mysql,给Discuz!扩展二个账户
    给mysql root账户设置密码,然后命令行步入mysql,创制新的库,并创办二个新的帐号对该库有全数权限:
    > create database discuz;
    > grant all on discuz.* to 'aming'@'localhost' identified by '123456aminglinux';
    > quit
  4. 安装Discuz!
    先绑定hosts 
    192.168.11.190  www.123.com
    浏览器输入:
    www.123.com/install/
    听别人说提醒,更改对应目录的权能
    cd /data/www
    chown daemon:daemon  data  uc_server/data  uc_client/data config   // 让那多少个目录帮忙apache运转帐号可写
  5. 为有个别设想主机配置客商认证
  6. 配备域名跳转
        <IfModule mod_rewrite.c>
            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^www.domain1.com$
            RewriteRule ^/(.*)$ $1 [R=301,L]
        </IfModule>
    即使是八个域名,能够那样设置:
        <IfModule mod_rewrite.c>
            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^www.domain.com [OR]
    威尼斯手机平台,        RewriteCond %{HTTP_HOST} ^www.domain1.com$
            RewriteRule ^/(.*)$ $1 [R=301,L]
        </IfModule>
    或者:    <IfModule mod_rewrite.c>
            RewriteEngine on
            RewriteCond %{HTTP_HOST} !^www.domain2.com$
            RewriteRule ^/(.*)$ $1 [R=301,L]
        </IfModule>
  7. 构造apache的访谈日志
    ErrorLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/oem.discuz.qq.com-error_%Y%m%d.log 86400"
        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/apache/bin/rotatelogs -l /usr/local/apache/logs/oem.discuz.qq.com-access_%Y%m%d.log 86400" combined env=!image-request
  8. 配备静态文件缓存
    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType image/gif  "access plus 1 days"
        ExpiresByType image/jpeg "access plus 24 hours"
        ExpiresByType image/png "access plus 24 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>
    还是利用mod_headers模块完成
    <ifmodule mod_headers.c> 
    # htm,html,txt类的文本缓存三个小时 
    <filesmatch ".(html|htm|txt)$"> 
    header set cache-control "max-age=3600" 
    </filesmatch> 
    # css, js, swf类的公文缓存叁个星期 
    <filesmatch ".(css|js|swf)$"> 
    header set cache-control "max-age=604800" 
    </filesmatch> 
    # jpg,gif,jpeg,png,ico,flv,pdf等公事缓存一年 
    <filesmatch ".(ico|gif|jpg|jpeg|png|flv|pdf)$"> 
    header set cache-control "max-age=29030400" 
    </filesmatch> 
    </ifmodule> 
  9. 构造防盗链
    SetEnvIfNoCase Referer "^" local_ref
    SetEnvIfNoCase Referer ".*.yourdomin.com" local_ref
    SetEnvIfNoCase Referer "^$" local_ref
    <filesmatch ".(txt|doc|mp3|zip|rar|jpg|gif)">
    Order Allow,Deny
    Allow from env=local_ref
    </filesmatch>
  10. 访谈调整
    <Directory /data/www/>
                Order deny,allow
                Deny from all
                Allow from 127.0.0.1
    </Directory>
    本着诉求的uri去限制
        <filesmatch "(.*)admin(.*)">
                Order deny,allow
                Deny from all
                Allow from 127.0.0.1
        </filesmatch>
    有个别某陆下取缔分析php
    <Directory /data/www/path>
        php_admin_flag engine off           
        <filesmatch "(.*)php">
                Order deny,allow
                Deny from all
        </filesmatch>
    </Directory>
  11. apache rewrite相关
    apache 约束内定user_agent 
    apache 限定有些目录无法访谈通过rewrite达成 
    apache rewrite 现身死循环 
    discuz伪静态配置:
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/topic-(.+).html$ /portal.php?mod=topic&topic=$1&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/article-([0-9]+)-([0-9]+).html$ /portal.php?mod=view&aid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/forum-(w+)-([0-9]+).html$ /forum.php?mod=forumdisplay&fid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ /forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/group-([0-9]+)-([0-9]+).html$ /forum.php?mod=group&fid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/space-(username|uid)-(.+).html$ /home.php?mod=space&$1=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/blog-([0-9]+)-([0-9]+).html$ /home.php?mod=space&uid=$1&do=blog&id=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/archiver/(fid|tid)-([0-9]+).html$ /archiver/index.php?action=$1&value=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ /plugin.php?id=$1:$2&%1

本文由威尼斯在线注册平台发布于威尼斯手机平台,转载请注明出处:apache rewrite 讲解

上一篇:还需要安装jpeg-6b 下一篇:没有了
猜你喜欢
热门排行
精彩图文