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

问题描述

安装程序在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 /测试”访问应用程序,但我只想通过“ URL”访问应用程序。 我该怎么办?

解决方法

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

有关URL重写的更多信息,您可以参考以下链接:url rewrite

如果您在创建url规则时遇到困难,则可以详细解释自己的需求,我可以为您编写一个演示。

尝试以下规则:

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

enter image description here

,

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

http://blabla.loc/test

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

http://blabla.loc
,

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