免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4329 | 回复: 6
打印 上一主题 下一主题

[Web] rewrite 重写内容而URL地址不变问题请教? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-27 12:46 |只看该作者 |倒序浏览
我的配置文件如下:
<VirtualHost *>
    RewriteLog       logs/rewrite.log
    RewriteLogLevel  3
    RewriteEngine    On
   RewriteCond %{HTTP_HOST} ^[a-z0-9]+\.pinkers\.com\.cn$
   RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1
   RewriteRule  ^/www\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/stati
cpage/company/index.html
   RewriteRule ^/(.*[a-zA-Z]+.*)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn
/webhome/home/$1/index.html
   RewriteRule  ^/([0-9]+)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/
staticpage/company/infolist/$1\.html
</VirtualHost>

如果按照这样的配置,URL重新定向是没有问题的。

但是如果我加上反向代理参数[P],则不能实现反向代理,不知道为什么,请指教

<VirtualHost *>
    RewriteLog       logs/rewrite.log
    RewriteLogLevel  3
    RewriteEngine    On
   RewriteCond %{HTTP_HOST} ^[a-z0-9]+\.pinkers\.com\.cn$
   RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1
   RewriteRule  ^/www\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/stati
cpage/company/index.html  [P]
   RewriteRule ^/(.*[a-zA-Z]+.*)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn
/webhome/home/$1/index.html  [P]
   RewriteRule  ^/([0-9]+)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/
staticpage/company/infolist/$1\.html [P]
</VirtualHost>

论坛徽章:
0
2 [报告]
发表于 2007-03-27 17:33 |只看该作者
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) init rewrite engine with requested uri /
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (3) applying pattern '^/?$' to uri '/'
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) rewrite / -> /www.pinkers.com.cn/
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (3) applying pattern '^/www\.pinkers\.com\.cn/?$' to uri '/www.p
inkers.com.cn/'
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) rewrite /www.pinkers.com.cn/ -> http://www.pinkers.com.cn/sh
ow/staticpage/company/index.html
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) forcing proxy-throughput with http://www.pinkers.com.cn/show
/staticpage/company/index.html
2.2.2.2 - - [27/Mar/2007:17:25:10 +0800] [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (1) go-ahead with proxy request proxy:http://www.pinkers.com.cn/
show/staticpage/company/index.html [OK]
日志信息如上,好像已经rewrite了,但是就是不redirect

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
3 [报告]
发表于 2007-03-27 17:38 |只看该作者
1. 停止apache
2. 清空rewrite和error log
3. 启动apache
4. 测试
5. 访问结果是什么?
6. 日志帖上来。

论坛徽章:
0
4 [报告]
发表于 2007-03-27 19:46 |只看该作者
因为你没配置apache支持mod_proxy这个模块.
cd apache2.0
./configure --enable-MODULE=shared --enable-so --with-mpm=worker --enable-rewrite=shared --enable-proxy=shared
make && make install

之后添加下面内容这个四行内容到http.conf中。
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

论坛徽章:
0
5 [报告]
发表于 2007-03-27 20:07 |只看该作者
我访问www.pinkers.com.cn,提示DNS错误
我的error_log
[Tue Mar 27 20:02:02 2007] [error] [client 202.96.179.188] proxy: DNS lookup fai
lure for: www.pinkers.com.cn returned by /

我的rewrite_log
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (2) init rewrite engine with requested uri /
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (3) applying pattern '^/?$' to uri '/'
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (2) rewrite / -> /www.pinkers.com.cn/
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (3) applying pattern '^/www\.pinkers\.com\.cn/?$' to uri '
/www.pinkers.com.cn/'
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (2) rewrite /www.pinkers.com.cn/ -> http://www.pinkers.com
.cn/show/staticpage/company/index.html
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (2) forcing proxy-throughput with http://www.pinkers.com.c
n/show/staticpage/company/index.html
202.96.179.188 - - [27/Mar/2007:20:02:02 +0800] [www.pinkers.com.cn/sid#80e8b30]
[rid#8253ae8/initial] (1) go-ahead with proxy request proxy:http://www.pinkers.c
om.cn/show/staticpage/company/index.html [OK]

论坛徽章:
0
6 [报告]
发表于 2007-03-27 20:10 |只看该作者
我的http.conf里面有loadmodule 相关proxy模块的语句啊,我已经打开了
而且我以前配置的http://IP地址/ddd,是能够实现地址跳转,而且显示的url不变的
配置文件如下:
NameVirtualHost *
<VirtualHost *>
    RewriteLog       logs/rewrite.log
    RewriteLogLevel  3
    RewriteEngine    On
    RewriteCond %{HTTP_HOST}   ^128\.129\.97\.135/(.*[a-zA-Z0-9]+.*)\/$
   RewriteRule ^/.*\/$  http://%{SERVER_NAME}/$1
   RewriteRule ^/www\/$ http://%{SERVER_NAME}
   RewriteRule ^/(.*[a-zA-Z]+.*)\/$  http://%{SERVER_NAME}/webhome/home/$1/index
.html [P]
   RewriteRule  ^/([0-9]+)\/$  http://%{SERVER_NAME}/show/staticpage/company/inf
olist/$1\.html [P]
</VirtualHost>

论坛徽章:
0
7 [报告]
发表于 2007-03-27 21:50 |只看该作者
如果这台apache服务器做proxy,这台服务器是不是要配置DNS,并且能够访问公网呢?
目前这台服务器我只让公网访问它,没有把它访问公网,DNS,放开
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP