Wildfly and Urlrewrite

Source: Internet
Author: User

Resources

Urlrewrite concept can be consulted: http://blog.csdn.net/crazy1235/article/details/8585310

Urlrewrite third-party library: http://tuckey.org/urlrewrite/

Wildfly Download: http://wildfly.org/downloads/

Installation and related configuration

    1. After completing the Wildfly download under Ubuntu, perform the "unzip Wildfly-10.1.0.final.zip "Unzip wildfly to the current directory, after completing this step you can move wildfly to other specified directories as needed, and modify the directory name such as" Wildfly10 ".
    2. Enter "./wildfly/bin" and execute "add-user.sh" to add a new user, such as "admin", this process specifies that the user role is not important.
    3. After completing the user registration, execute "standalone.sh" to start Wildfly application Server.
    4. After the server is started, access by default: http://localhost:9990 deploy the Web app to complete the deployed app from http://localhost:8080 access.

Add the following to the head of "Web-inf/web.xml":

<filter>    <filter-name>UrlRewriteFilter</filter-name>    <filter-class> org.tuckey.web.filters.urlrewrite.urlrewritefilter</filter-class>  </filter>  < filter-mapping>    <filter-name>UrlRewriteFilter</filter-name>    <url-pattern>/*</ url-pattern>    <dispatcher>REQUEST</dispatcher>    <dispatcher>forward</dispatcher >  </filter-mapping>

To use a third-party Urlrewrite library, you need to copy "Urlrewritefilter-4.0.3.jar" to the "web-inf/lib" of the WEB app, and then add the following jboss-web.xml under "Web-inf":

<?xml version= "1.0" encoding= "UTF-8"?> <jboss-web xmlns= "Http://www.jboss.com/xml/ns/javaee" xmlns:xsi= " Http://www.w3.org/2001/XMLSchema-instance "  xsi:schemalocation="  Http://www.jboss.com/xml/ns/javaee  http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd ">  <context-root>/</context-root> </jboss-web>

The urlrewrite rule is defined in the following "Web-inf/urlrewrite.xml" file:

<?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>          <from>/hello/abc/</from>          <to type=" forward ">/</to>      </rule>    <rule>          <from>/hallo/</from>          <to type=" Forward ">/</to>      </rule></urlrewrite>

Once the deployment and related configurations are complete, you can access the deployed Web App through the following URLs:

http://localhost:8080/http://localhost:8080/hello/abc/

http://localhost:8080/hallo/

  

Wildfly and Urlrewrite

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.