Urlrewrite does not work. Two domain names point to the same project under the same IP.

the website is divided into foreground and background, and there are 2 domain names.

enter domain name 1 to access the foreground
enter domain name 2 to access the background

but I can only see

after typing in my browser.

"this page does not work properly"

There is no problem with the

project. At first, I didn"t use the domain name, and I can access it by binding IP. Now I don"t know what to do after using the domain name, and I can"t see the error message. The configuration is as follows

.

nginx used

1. Conf.d

in nginx
server_name  1 2;

web.xml under 2.WEB-INF

<filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>
            org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
        </filter-class>
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>WARN</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
            <dispatcher>REQUEST</dispatcher>
               <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

3.urlrewrite.xml is as follows

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
        "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>
    <rule>
        <note></note>
         <condition type="server-name">2</condition>
        <from>^/admin/index.html$</from>
        <to>/admin/login.htm</to>
    </rule>
    <rule>
        <note></note>
        <from>^/$</from>
        <to>/index.html</to>
    </rule>

</urlrewrite>

server under the conf directory under 4.tomcat

      <Host name="1" appBase="" unpackWARs="true" autoDeploy="true">
          <Alias>2</Alias>  
 </Host>

ask you what went wrong, or I didn"t post enough.

Mar.01,2021

server_name domain name 1 domain name 2;
There is obviously something wrong with this step. How is the rest of the configuration file written? The two domain names are written together, and no matter how the reverse proxy rules match, they can't point to two projects. Your way of writing is to make two domain names correspond to an ip, such as this.is.mysite.com and this.is.also.mysite.com can be accessed to the same website.
in order to achieve your goal, you can write a project.conf for each project and put it in the conf/include directory under the nginx directory. Two * .conf files can be proxied to two ip respectively. The specific operation method also requires specific treatment of specific problems (that is, it is recommended to check the nginx configuration rules yourself).

in addition, nginx also provides rewrite rules. If redirection is really needed, it is much faster to write rewrite in nginx than in server configurations such as tomcat.

Menu