阿帕奇重写用的ProxyPass [英] apache rewrite with proxypass

查看:175
本文介绍了阿帕奇重写用的ProxyPass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重写和代理相结合传球和具有重写的问题。以下是我有

I am trying to combine a rewrite and a proxy pass and having issues with the rewrite. Here is what I have

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.world.net
RewriteRule %{HTTP_HOST} http://newexample.newworld.net:7802/apex/f?p=208 [R,P]
ProxyPass / http://newexample.newworld.net:7802/

增强了ProxyPass工作,但我无法弄清楚如何获得初始重定向。因此,如果用户将在example.world.net/apex/f?p=208它进入newexample.newworld.net:7802/apex/f?p=208~~V和口罩的网址。

The proxypass is working, but I can't figure out how to get the initial redirect. So if the user puts in example.world.net/apex/f?p=208 it goes to newexample.newworld.net:7802/apex/f?p=208 and masks the url.

不过,我需要得到example.world.net重定向到example.world.net/apex/f?p=208~~V如果顶点/ F·P = 208是不是在URL中。

However I need to get example.world.net to redirect to example.world.net/apex/f?p=208 if the apex/f?p=208 is not in the url.

推荐答案

您不能重定向的的代理在同一时间。你重写规则标志 [R,P] 这是重定向和代理。你需要一个或其他在这里。此外,您的规则的正则表达式是永远不会匹配%{HTTP_HOST} ,除非您的网址是字面上: http://example.world.net/ %{HTTP_HOST} 。你需要将它更改为:

You can't redirect and proxy at the same time. Your rewrite rule flags are [R,P] which is "redirect" and "proxy". You'll need one or the other here. Also, your rule's regex is never going to match %{HTTP_HOST}, unless your URL is literally: http://example.world.net/%{HTTP_HOST}. You'll need to change it to:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.world.net
RewriteCond %{QUERY_STRING} !(^|&)p=208(&|$)
RewriteRule ^/?$ /apex/f?p=208 [L,QSA,R]

如果URL地址栏显示 http://example.world.net/ HTTP这将浏览器重定向://例子。 world.net/apex/f?p=208 。然后,它是由代理采取 /顶点/在fp = 208 并代理 http://newexample.newworld.net? 7802 /

This will redirect the browser if the URL address bar says http://example.world.net/ to http://example.world.net/apex/f?p=208. Then, it's up to the proxy to take /apex/f?p=208 and proxy it to http://newexample.newworld.net:7802/.

有这么的mod_proxy和mod_rewrite的不会起到很好地在一起,因为两者都可以最终得到应用到相同的URL的可能性。如果您发现两者都得到在同一时间应用,然后更改的ProxyPass 行:

There's a possibility that mod_proxy and mod_rewrite won't play nicely together because both can end up getting applied to the same URL. If you find that both are getting applied at the same time, then change the ProxyPass line to:

RewriteRule ^/?(.*)% http://newexample.newworld.net:7802/$1 [L,P,QSA]

这篇关于阿帕奇重写用的ProxyPass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆