Chinaunix首页 | 论坛 | 博客
  • 博客访问: 244414
  • 博文数量: 7
  • 博客积分: 3042
  • 博客等级: 中校
  • 技术积分: 566
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 14:37
文章分类
文章存档

2011年(1)

2008年(6)

我的朋友

分类: 系统运维

2008-03-13 13:46:43

要求是访问时看到的内容是,在apache的教程中有
关于Redirect的指令,但是只能实现跳转,跳转后浏览器中的域名也变了。要想实现浏览器中域名保存不变的话,需要用RewriteRule的P指令,调用apache的代理功能来实现。完整的rewrite规则如下:
 

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^(.*)$ http://bbs.yyy.com/$1 [P,L]
</IfModule>

将上面的内容保存为.htaccess放置到目录下就可以实现我们的目标了,RewriteRule完整的指令如下:

Flag Description
redirect[=status-code] Sends a status code between 300 and 400, specified by status-code. The default is 302.
R[=status-code] Same as "redirect"
forbidden Forces Stronghold to return a status code of 403 ("Forbidden"). This is useful for conditionally blocking URLs.
F Same as "forbidden"
gone Forces Stronghold to return a status code of 410 ("Gone").
G Same as "gone"
proxy Forces the substitution part through the proxy module. The substitution string must be a valid URI. This is useful as a sophisticated alternative to the ProxyPass directive.
P Same as "proxy"
last Force the rewrite process to end here
L Same as "last"
next Reruns the rewrite process, starting with the first instance of RewriteRule and using the outcome of the current rewrite process as new input
N Same as "next"
chain Chains the current rule with the next rule, provided that the current rule matches
C Same as "chain"
type=mime-type Forces Stronghold to return the file as the specified MIME type
T=mime-type Same as "type"
nosubreq Indicates that the current rule applies only if the current request is not an internal subrequest
NS Same as "nosubreq"
passthrough Passes the substitution to the next handler, which should immediately follow the current RewriteRule
PT Same as "passthrough"
skip=n Skips the next n rules in a sequence if the current rule matches
S=n Same as "skip"
env=VARIABLE:VALUE Sets the environment variable VARIABLE to the value VALUE
E=VARIABLE:VALUE Same as "env"

如果设置正确后,还不成功,并且apache的错误日志有

[Thu Mar 13 13:47:21 2008] [error] [client xx] Attempt to serve directory: proxy:
[Thu Mar 13 13:47:21 2008] [error] [client xx] File does not exist: proxy: referer:

那是因为没有将apache的代理功能打开,需要修改httpd.conf配置文件,添加

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

将代理功能打开,才能用p命令

 

阅读(1907) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Lua做web的小实例

给主人留下些什么吧!~~