使用隐式重定向的 Apache 重写

发布于 2024-08-01 19:17:14 字数 1438 浏览 6 评论 0原文

一段时间以来我一直在尝试这样做,但没有成功。 我会提前说,这可能是一个新手问题,所以很抱歉,但我确实需要一些帮助。

我正在尝试将 cgi-bin/java-rmi.cgi 的请求重定向到 tomcat 上的 servlet(来自 apache)。 我已成功重定向到 servlet,但无法执行隐式重定向(对客户端隐藏 url 更改)。

这是强制性的,因为如果重定向,rmi 将无法工作,所以我必须向客户端隐藏它。

现在我的 httpd.conf 看起来像这样(显然只有相关的东西)

RewriteEngine on
RewriteLog logs/rewrite.log
RewriteLogLevel 9
RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P]

Alias /RMIServlet "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet/">
Options Indexes FollowSymLinks
</Directory>

include "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/mod_jk.conf"

另外,我的 mod_jk.conf 看起来像这样(同样,只有相关的东西)

# Send everything!! to worker ajp13
JkMount / ajp13
JkMount /* ajp13

(虽然我认为 mod_jk.conf 与问题无关)

我也启用了这些:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module mo

dules/mod_rewrite.so

每当我尝试打开 http://localhost/cgi-bin/ java-rmi.cgi 页面以 url http://localhost/RMIServlet 打开,这不好。

我究竟做错了什么?

谢谢!

I've been trying to do this for some time unsuccesfully.
I'll say in advance that this is probably a newbie question so apologies but I do need some assistance with this.

I am trying to redirect requests to cgi-bin/java-rmi.cgi to a servlet on tomcat (from apache).
I've managed to redirect to the servlet successfully but I have not been able to do an implicit redirections (hiding the url change from the client).

This is mandetory since rmi will not work if it is redirected so I have to hide this from the client.

Right now my httpd.conf looks like this (only the relevant stuff obviously)

RewriteEngine on
RewriteLog logs/rewrite.log
RewriteLogLevel 9
RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P]

Alias /RMIServlet "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Tomcat 6.0/webapps/RMIServlet/">
Options Indexes FollowSymLinks
</Directory>

include "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/mod_jk.conf"

additionally, my mod_jk.conf looks like this (again, only relevant stuff)

# Send everything!! to worker ajp13
JkMount / ajp13
JkMount /* ajp13

(although I presume mod_jk.conf has nothing to do with the problem)

I also enabled these:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module mo

dules/mod_rewrite.so

Whenever I try to open http://localhost/cgi-bin/java-rmi.cgi the page opens with the url http://localhost/RMIServlet which is not good.

What am I doing wrong?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丿*梦醉红颜 2024-08-08 19:17:14
  1. Dav 错误,使用 [P] 替换需要是合格的 URI,包括协议和主机名。

    Dav 错误

  2. mod_proxy 是否真的处于活动状态并且配置正确? 抱歉,我无法帮助您,因为我还没有使用过此操作。

  3. 在重写 URL 之前尝试定义 RMIServlet。

  4. 也许在您的规则之后正在进行另一次重写,请尝试为最后一个规则附加 L,因此使其成为 RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P ,L]

  1. Dav is wrong, with [P] the replacement needs to be a qualified URI, including protocol and hostname.

  2. Is mod_proxy really active and configured correctly? Sorry, I can't help you with that, as I have not used done this yet.

  3. Try defining RMIServlet before rewriting the URL.

  4. Perhaps there is another rewriting going on after your rule, try appending L for last rule, so make it RewriteRule ^/cgi-bin/java\-rmi\.cgi http://localhost/RMIServlet [P,L]

旧城烟雨 2024-08-08 19:17:14

试试这个? (即省略主机部分?)

RewriteRule ^/cgi-bin/java\-rmi\.cgi /RMIServlet [P]

Try this instead? (Namely, omit the host portion?)

RewriteRule ^/cgi-bin/java\-rmi\.cgi /RMIServlet [P]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文