mod_rewrite - >重写规则替换原始URL中的应用程序上下文部分

时间:2017-12-06 22:30:03

标签: mod-rewrite apache2 virtualhost httpd.conf

请注意我已经在“服务器故障”上提出了这个问题,没有出现任何问题,所以发布在SO上。

我有要求用户在浏览器中输入类似http://example.com/Welcome的网址,但我需要将其发送到http://myip.com/someapp/next.html,所以我在httpd.conf文件中写了虚拟主机:

<VirtualHost *:80>
     ProxyRequests off
     ProxyPreserveHost On
     RewriteEngine On

     RewriteRule "^/(.*)" "http://myip.com/someapp/next.html" [P]
     ProxyPassReverse "/" "http://myip.com/someapp/next.html"

</VirtualHost>

这部分是有效的。当用户输入网址http://example.com/Welcome时,它将被http://example.com替换。如何保留完整的网址(http://example.com/Welcome)?我将不胜感激。

修改 这是围绕呼叫的access_log

184.180.123.46 - - [06/Dec/2017:21:10:41 +0000] "GET /myip.com/images/logo.png HTTP/1.1" 200 6697 "http://example.com/Welcome" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
184.180.123.46 - - [06/Dec/2017:21:10:51 +0000] "POST /myip/somepage HTTP/1.1" 200 7 "http://example.com/Welcome" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
184.180.123.46 - - [06/Dec/2017:21:10:52 +0000] "GET / HTTP/1.1" 200 3391 "http://example.com/Welcome" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
184.180.123.46 - - [06/Dec/2017:21:11:01 +0000] "GET / HTTP/1.1" 200 3391 "http://example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"

0 个答案:

没有答案