首页 > 解决方案 > 使用 Wildfly 独立处理程序重定向我的 url 时如何设置占位符?

问题描述

我正在尝试使用 Standalone.xml 中的以下设置重定向我的 URL:

<server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
            <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
            <host name="default-host" alias="localhost">
                <location name="/en/" handler="en"/>
                <location name="/de/" handler="de"/>
                <location name="/" handler="de"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>
        <servlet-container name="default">
            <jsp-config/>
            <websockets/>
        </servlet-container>
        <handlers>
            <file name="en" path="${jboss.home.dir}/standalone/deployments/en"/>
            <file name="de" path="${jboss.home.dir}/standalone/deployments/de"/>
        </handlers>

我的处理程序指向 Wildfly 服务器的部署文件夹中匹配的 Angular 前端项目,其中也部署了我的 EAR 文件。

这工作正常,除了一种情况:如果我刷新我的详细信息页面,它看起来像这样:localhost:8080/en/details/1234我收到一个错误

404 - Page not found 我已经尝试过<location name="/en/details/1234" handler="en"/>哪个有效,但显然只适用于那个特定的 id。

据我了解,这可以通过添加类似的东西来解决 <location name="/en/details/(.*)" handler="en"/>

我的问题是我无法弄清楚如何在“详细信息/”之后放置一个像正则表达式这样的占位符。这甚至可能吗?或者有没有更好的方法来处理这个重定向/重写问题?

我已经试undertow-handlers.conf了一下,但感觉它从未真正触发我在那里实施的重写规则。

标签: url-rewritingwildflyurl-redirection

解决方案


推荐阅读