Jboss + mod_rewrite =?

我有2个服务器,Apache和Jboss。 使用JKmount .war文件被挂载并呈现一个复杂的网站。

例如:

JkMount /directory/* ajp13 Alias /directory /jboss/server/default/deploy/directory.war <Directory /jboss/server/default/deploy/directory.war> Order allow,deny allow from all Options -Indexes </Directory> <Directory /jboss/server/default/deploy/directory.war/WEB-INF> deny from all </Directory> 

我想在Apache端使用mod_rewrite来改变mod_jk返回的URL。

例如:

 RewriteEngine On RewriteCond %{REMOTE_ADDR} !^192.168.1.1$ RewriteRule /.* http://server.example/redirect.html [R=301,L] 

目前上面的代码只影响Apache返回的图像,而不会影响mod_jk返回的页面。

这可能吗? 它是如何完成的?

有一个类似的问题在StackOverFlow询问,但给出一个select,如果有可能我想处理这个内部的Apache,而不是改变Jboss的configuration。

服务器是OpenSuse 11.1,我怀疑可能有一些模块优先顺序问题,但我还没有能够证实这一点。

url的例子是:

 http://site.example/directory/index.jsp http://site.example/foo/other.html 

在这个例子中,第一个URL使用上面configuration中列出的指令安装在mod_jk中,不会被mod_rewrite重写。 第二个URL是Apache站点中的正常目录,并被正确地重写。

谢谢大家

经过漫长的search,我find了答案。

重写指令必须全局放置在(虚拟)主机中,而不是在.htaccess中。 Apache似乎并没有实际parsing这些文件,因为mod_jk提供的文件不是该结构的一部分; 这是有道理的,如果你考虑一下。 然而,它将应用适用于整个主机的mod_rewrite规则。

对不起,不能评论,我新来这里…你可以给一个例子从mod_jk返回的url。 看起来正则expression式不适合返回的页面。

尝试将所有redirect到http://server.example/redirect.html :

 RewriteRule .* http://server.example/redirect.html [R=301,L] 

如果这个工作,它的正则expression式,这麻烦你。

让我稍微解释一下。

你有一个如下所示的URI: http : //foo.bar.com/anything

您的正则expression式(/.*)现在正在search斜线,然后是某个东西。 但是在乌里,没有任何东西。

如果你有一个图像:例如

http://foo.bar.com/images/image.png比in / in images / image.png和正则expression式匹配,并做redirect。

如果你想redirectsomesite到另一个服务器:

http://foo.bar.com/somesite – > http://bar.foo.com使&#x7528;

 RewriteRule somesite.* http://server.example/redirect.html [R=301,L] 

对不起,不能发表评论,但是为了回应你的回答Antitribu,你也可以把重写语句放在一个<Location>上下文中。 有一个很好的描述何时使用<File>,<Location>,.htaccess等的apache手册 。