歡迎您光臨本站 註冊首頁

rewrite 重寫內容而URL地址不變問題請教?

←手機掃碼閱讀     火星人 @ 2014-03-05 , reply:0

rewrite 重寫內容而URL地址不變問題請教?

我的配置文件如下:
<VirtualHost *>
    RewriteLog       logs/rewrite.log
    RewriteLogLevel  3
    RewriteEngine    On
   RewriteCond %{HTTP_HOST} ^+\.pinkers\.com\.cn$
   RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1
   RewriteRule  ^/www\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/stati
cpage/company/index.html
   RewriteRule ^/(.*+.*)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn
/webhome/home/$1/index.html
   RewriteRule  ^/(+)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/
staticpage/company/infolist/$1\.html
</VirtualHost>

如果按照這樣的配置,URL重新定向是沒有問題的。

但是如果我加上反向代理參數,則不能實現反向代理,不知道為什麼,請指教

<VirtualHost *>
    RewriteLog       logs/rewrite.log
    RewriteLogLevel  3
    RewriteEngine    On
   RewriteCond %{HTTP_HOST} ^+\.pinkers\.com\.cn$
   RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1
   RewriteRule  ^/www\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/stati
cpage/company/index.html  
   RewriteRule ^/(.*+.*)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn
/webhome/home/$1/index.html  
   RewriteRule  ^/(+)\.pinkers\.com\.cn/?$  http://www.pinkers.com.cn/show/
staticpage/company/infolist/$1\.html
</VirtualHost>
《解決方案》

2.2.2.2 - - [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) init rewrite engine with requested uri /
2.2.2.2 - - [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (3) applying pattern '^/?$' to uri '/'
2.2.2.2 - - [www.pinkers.com.cn/sid#80e8b30][rid#e6
b02538/initial] (2) rewrite / -> /www.pinkers.com.cn/
2.2.2.2 - - [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 - - [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 - - [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 - - [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
日誌信息如上,好像已經rewrite了,但是就是不redirect
《解決方案》

1. 停止apache
2. 清空rewrite和error log
3. 啟動apache
4. 測試
5. 訪問結果是什麼?
6. 日誌帖上來。
《解決方案》

因為你沒配置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>
《解決方案》

我訪問www.pinkers.com.cn,提示DNS錯誤
我的error_log
proxy: DNS lookup fai
lure for: www.pinkers.com.cn returned by /

我的rewrite_log
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(2) init rewrite engine with requested uri /
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(3) applying pattern '^/?$' to uri '/'
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(2) rewrite / -> /www.pinkers.com.cn/
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(3) applying pattern '^/www\.pinkers\.com\.cn/?$' to uri '
/www.pinkers.com.cn/'
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(2) rewrite /www.pinkers.com.cn/ -> http://www.pinkers.com
.cn/show/staticpage/company/index.html
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(2) forcing proxy-throughput with http://www.pinkers.com.c
n/show/staticpage/company/index.html
202.96.179.188 - - [www.pinkers.com.cn/sid#80e8b30]
(1) go-ahead with proxy request proxy:http://www.pinkers.c
om.cn/show/staticpage/company/index.html
《解決方案》

我的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/(.*+.*)\/$
   RewriteRule ^/.*\/$  http://%{SERVER_NAME}/$1
   RewriteRule ^/www\/$ http://%{SERVER_NAME}
   RewriteRule ^/(.*+.*)\/$  http://%{SERVER_NAME}/webhome/home/$1/index
.html
   RewriteRule  ^/(+)\/$  http://%{SERVER_NAME}/show/staticpage/company/inf
olist/$1\.html
</VirtualHost>
《解決方案》

如果這台apache伺服器做proxy,這台伺服器是不是要配置DNS,並且能夠訪問公網呢?
目前這台伺服器我只讓公網訪問它,沒有把它訪問公網,DNS,放開

[火星人 ] rewrite 重寫內容而URL地址不變問題請教?已經有770次圍觀

http://coctec.com/docs/service/show-post-40255.html