[:thisport]/前缀重定向到外部的URL.如果code不指定,将用缺省
的302 HTTP状态码。
2) F(force URL to be forbidden)禁用URL,返回403HTTP状态码。
3) G(force URL to be gone) 强制URL为GONE,返回410HTTP状态码。
4) P(force proxy) 强制使用代理转发。
5) L(last rule) 表明当前规则是最后一条规则,停止分析以后规则的重写。
6) N(next round) 重新从第一条规则开始运行重写过程。rewrite规则
7) C(chained with next rule) 与下一条规则关联 如果规则匹配则正常处理,该
标志无效,如果不匹配,那么下面所有关联的规则都跳过。
8) T=MIME-type(force MIME type) 强制MIME类型
9) NS (used only if no internal sub-request) 只用于不是内部子请求
10) NC(no case) 不区分大小写
11) QSA(query string append) 追加请求字符串
12) NE(no URI escaping of output) 不在输出转义特殊字符例如:
RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
将能正确的将/foo/zoo转换成/bar?arg=P1=zed
13) PT(pass through to next handler) 传递给下一个处理例如:
RewriteRule ^/abc(.*) /def$1 [PT] # 将会交给/def规则处理
Alias /def /ghi
14) S=num(skip next rule(s)) 跳过num条规则
15) E=VAR:VAL(set environment variable) 设置环境变量
4.Apache rewrite例子集合 在 httpd 中将一个域名转发到另一个域名虚拟主机世界近期更
换了域名,新域名为 , 更加简短好记。这时需要将原来的域名
webhosting-world.com, 以及论坛所在地址 webhosting-world.com/forums/定向到新的
域名,以便用户可以找到,并且使原来的论坛 URL 继续有效而不出现 404 未找到,比如原
来的, 让它在新的域名下继续有
效,点击后转发到, 这就需要用 apache
的 Mod_rewrite 功能来实现。在中添加下面的重定向规则:
RewriteEngine On #
Redirect webhosting-world.com/forums to bbs.wbhw.com
RewriteCond %{REQUEST_URI} ^/forums/
RewriteRule /forums/(.*) $1 [R=permanent,L] #
Redirect webhosting-world.com to wbhw.com
RewriteCond %{REQUEST_URI} !^/forums/
RewriteRule /(.*) $1 [R=permanent,L]
添加了上面的规则以后, 里的全部内容如下:
Servername btmuchina.51job.com
Documentroot //htdocs/companyads/campus/btmu
CustomLog "|/usr/local/sbin/cronolog /var//logs/`hostname`_btmuaccess_log%m%d" combined env=!image-request
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-24370-2.html
假货