繁体   English   中英

使用直接 URL 重定向 Tomcat 9 和 IIS

[英]ReDirect Tomcat 9 and IIS with direct URL

设置在 Windows Server 2019 上:Tomcat 9.0.38,测试应用程序是我的 server.xml 配置文件的一部分:

    <Connector
    address="x.x.x.x"
    port="8000" 
    URIEncoding="UTF-8" 
    protocol="org.apache.coyote.http11.Http11NioProtocol" 
    connectionTimeout="20000" 
    redirectPort="8443" 
    compression="on" 
    compressionMinSize="1024" 
    noCompressionUserAgents="gozilla, traviata" 
    compressibleMimeType="text/html,text/xml,text/css,text/plain,text/javascript, image/jpeg"
    server="Tomcat"/>

    <Connector
    protocol="AJP/1.3" 
    address="x.x.x.x" 
    port="8009" 
    redirectPort="8443" 
    tomcatAuthentication="false" 
    secretRequired="false" 
    packetSize="65536" />

IIS 也工作正常

Add Virtual Directory...
-> Jakarta

还配置了连接器(isapi_redirect.dll)

    worker.list=local 
    worker.local.type=ajp13
    worker.local.host=x.x.x.x
    worker.local.port=8009
    worker.local.max_packet_size=65536

    /test/*=local
    /test=local

现在我可以通过“url/test”访问应用程序,但我只想通过“url”访问应用程序。 我怎样才能做到这一点?

网址/测试是什么意思? 不应该 test 是 url 的一部分,还是您的 url 指的是主机名? 如果是这样,您可以尝试使用 url 重写。

有关 url rewrite 的更多信息,您可以参考此链接: url rewrite

如果你在创建url规则有困难,那么你可以详细说明你的需求,我可以为你写一个demo。

试试这个规则:

<rule name="test" stopProcessing="true">
    <match url="^test$" />
      <action type="Redirect" url="http://{HTTP_HOST}" />
</rule>

在此处输入图片说明

我的意思是,现在我可以通过以下方式访问该应用程序:

http://blabla.loc/test

但我只想通过以下方式访问应用程序:

http://blabla.loc

我的解决方案可能不是最好的,但工作正常我将文件夹/应用程序从 test 更改为 root,现在我可以直接访问该应用程序

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM