Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache http服务器重写或重定向_Apache_Http_Tomcat_Redirect_Rewrite - Fatal编程技术网

Apache http服务器重写或重定向

Apache http服务器重写或重定向,apache,http,tomcat,redirect,rewrite,Apache,Http,Tomcat,Redirect,Rewrite,我有一个功能正常的环境,有一个apache http服务器(负载平衡器),后端有一个tomcat服务器集群。但有一个问题困扰着我,我无法将请求url重定向或重写到我需要的位置。比如说, request url - http://www.yyy.com 我想将其重定向或重写到 http://www.yyy.com/mycontext 我尝试重定向和重写,但没有成功 RewriteRule ^/$ http://www.yyy.com/mycontext/ [L] - Error (c

我有一个功能正常的环境,有一个apache http服务器(负载平衡器),后端有一个tomcat服务器集群。但有一个问题困扰着我,我无法将请求url重定向或重写到我需要的位置。比如说,

request url - http://www.yyy.com
我想将其重定向或重写到

http://www.yyy.com/mycontext
我尝试重定向和重写,但没有成功

RewriteRule    ^/$  http://www.yyy.com/mycontext/  [L] - Error (can't fine the url)
然后我试了一下

Redirect / http://www.yyy.com/mycontext/ - this results in the following, 

http://www.yyy.com/mycontext/mycontext/mycontext/mycontext/mycontext/........... repeats.  
我无法找出正确的条件语句。我尝试使用服务器变量来编写重写条件,但我做了一些错误的事情,它被忽略了

感谢您的帮助。我在这方面没有多少经验

而这个
ProxyPass/http://www.yyy.com/mycontext/
www.yyy.com的配置中


是的,在虚拟主机中

不确定负载平衡器如何工作。您正在将请求代理回您自己,它将立即耗尽线程,因为每个代理请求都在自己的线程上运行

  • /
    请求到达您的虚拟主机
  • ProxyPass
    reverse将其代理到
    http://www.yyy.com/mycontext/
    ,它本身就是
  • /mycontext/
    请求到达您的虚拟主机
  • ProxyPass
    reverse将其代理到
    http://www.yyy.com/mycontext/mycontext/
  • /mycontext/mycontest/
    的请求到达您的虚拟主机
  • ProxyPass
    reverse将其代理到
    http://www.yyy.com/mycontext/mycontext/mycontext/
  • 等等

    我想你可能在寻找的是:

    RewriteCond %{REQUEST_URI} !^/mycontext/
    RewriteRule ^(.*)$ /mycontext/$1 [L]
    

    但这与您的负载平衡器或tomcat服务器无关。

    您可以显示您的反向代理/负载平衡器指令吗?我尝试使用proxypass,如下所示:proxypass/这导致了一个错误-服务器没有线程来处理请求。考虑提高TyReScript子设置。因此,我开始尝试重定向和重写,以及这个
    ProxyPass/http://www.yyy.com/mycontext/
    www.yyy.com
    的配置中?在virtualhost中是。谢谢你的回复,乔恩。就这样!。我在努力学习语法。