URL eXist-db 中的重写问题 - DNS A 记录 - Jetty 服务器

URL rewriting issue in eXist-db - DNS A record - Jetty server

我有一个 DNS A 记录,我希望将我的应用转发到该记录。我已经添加到 $EXIST_HOME/webapp/WEB-INF/controller-config.xml 这一行:

<root server-name="something.mydomain.com" pattern=".*" path="xmldb:exist:///db/apps/myapp"/>

这是我在 controller.xql 中关于 app-root 的内容:

else if (contains($exist:path,"app-root")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
    <forward url="{$exist:controller}/{substring-after($exist:path, '$app-root/')}">
        <set-header name='Cache-Control' value="no"/>
    </forward>
</dispatch>

现在,当我将浏览器指向 something.mydomain.com 时,我正确地看到了 db/apps/myapp 内容(仍在研究如何让该文件夹中的 index.html 生效,但这是次要的问题)。 something.mydomain.com/index.html 转换为“http://something.mydomain.com/exist/index.html”,我看到了页面。尽管如此,我已经丢失了所有指向图像、CSS 样式等的链接。经过检查,我看到,例如,$app-root 没有被解压(例如,我的横幅保留地址 '$[ =37=.jpg' 在我的页面的 HTML 来源中)。我已将其更改为 /resources/img/banner.jpgresources/img/banner.jpg 等,但我没有任何运气。不用说,在更改 $EXIST_HOME/webapp/WEB-INF/controller-config.xml 之前一切都运行良好。我错过了什么?

其他相关问题:

我没有按照 eXist:NoSQL 文档数据库和应用程序平台 一书中的说明在 $EXIST_HOME/tools/jetty/etc/jetty.xml 中找到 <Set name="contextPath">/exist</Set>。我能找到它吗,以便我可以删除 URL 的 'exist' 位?

好的,部分原因是我对这个主题的无知以及我想要提供的一些文件的配置。自从我有

<root server-name="something.mydomain.com" pattern=".*" path="xmldb:exist:///db/apps/myapp/subfolder"/>

在我的 $EXIST_HOME/webapp/WEB-INF/controller-config.xml 中,eXist-db 正在寻找 /subfolder 文件夹中的控制器。模块和配置文件(包括他 controller.xql)位于 myapp 文件夹中,因此 eXist-db 正在使用该控制器(对控制器的请求返回到 myapp 文件夹,因为子文件夹中没有控制器) .将控制器放入子文件夹后,我编辑了这个:

else if (ends-with($exist:resource, ".html")) then
    (: the html page is run through view.xql to expand templates :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <view>
            <forward url="../modules/view.xql"/>
        </view>
        <error-handler>
            <forward url="../error-page.html" method="get"/>
            <forward url="./modules/view.xql"/>
        </error-handler>
    </dispatch>

这样我仍然可以使用 myapp 文件夹中的 view.xql。

但这只是部分解决了问题,因为现在 $app-root 没有被解压。例如,如果我的 css 在 myapp/resources/css/ 中并且是从子文件夹目录中的文件引用的,则不会加载它。到目前为止,我发现的唯一解决方法是使用从子文件夹中的页面引用的每个 css、jpg、js 等的完整 http:// 地址进行硬编码。有没有办法告诉 eXist-db 在 URL 重写规则中指定的文件夹中查找一个文件夹?我也尝试过:

else if (contains($exist:path,"app-root")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
    <forward url="xmldb:exist://db/apps/myapp">
        <set-header name='Cache-Control' value="no"/>
    </forward>
</dispatch>

,在 exist: 之后有两个或三个斜杠,这不起作用(错误 500),forward url="http://fulladdress/db/apps/myapp".

也不起作用

还有,现在

else if ($exist:path eq "/") then
    (: forward root path to index.xql :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <redirect url="index.html"/>
    </dispatch> 

在 subfolder/controller.xql 中正确转发一个空的 $exist:path 到 index.html.

最后,我设法找到了较新版本的 eXist-db 放置 <Set name="contextPath">/exist</Set> 代码的位置。它在 eXist-db/tools/jetty/webapps/exist-webapp-context.xml.