Redirect URL since Tomcat 8.5 - ootb, easy to use, update proof

Version 2


    a frequently overlooked detail that can make work easier: rewrite valve. No plugin any more, no additional apache webserver, it works ootb.

    "The rewrite valve implements URL rewrite functionality in a way that is very similar to mod_rewrite from Apache HTTP Server."


    How does it work?

    1. activate url rewriting
    2. configure your rules
    3. restart your tomcat



    Add the following line to server.xml as the first element in <host> tag

          <Engine defaultHost="localhost" name="Catalina">
             <Host appBase="webapps"
                   <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />



    Create a "rewrite. config" file in the directory "conf/Catalina/localhost" with your rewrite rules. Here are a few examples of what we do with it.

    # Mark each environment with its own favicon, survive each BMC update

    RewriteRule    ^.*/favicon\.ico$             /arsys/<your own folder under "ARSystem/midtier">/favicon.ico [NC,L]


    # In case an FQDN is always required, e. g. for RSSO integration

    RewriteCond    %{HTTP_HOST}          !^.*\.your\.destination\.domain [NC]
    RewriteCond    %{HTTP_HOST}          !^$
    RewriteRule      ^/(.*)$                           http://your_server.your.destination.domain/$1 [R]


    # Short URLs in all ITSM notifications

    RewriteCond     %{QUERY_STRING}  !^$
    RewriteCond     %{QUERY_STRING}  ^showTicket=(INC|CRQ|TAS|PBI)(\d{12})$
    RewriteRule     ^.*$                               - [E=TicketClass:%1,E=TicketID:%1%2,E=TicketBasePath:%{CONTEXT_PATH}/servlet/ViewFormServlet?server=<your_arserver>&form]

    RewriteCond     %{ENV:TicketClass}    INC
    RewriteRule     ^.*$                               %{ENV:TicketBasePath}=HPD:Help\+Desk&ion&qual='1000000161'=\%22%{ENV:TicketID}\%22 [NE,R,L]
    RewriteCond     %{ENV:TicketClass}    CRQ
    RewriteRule     ^.*$                               %{ENV:TicketBasePath}=CHG:Infrastructure\+Change&qual='1000000182'=\%22%{ENV:TicketID}\%22 [NE,R,L]
    RewriteCond     %{ENV:TicketClass}    TAS
    RewriteRule     ^.*$                               %{ENV:TicketBasePath}=TMS:Task&qual='1'=\%22%{ENV:TicketID}\%22 [NE,R,L]
    RewriteCond     %{ENV:TicketClass}    PBI
    RewriteRule     ^.*$                               %{ENV:TicketBasePath}=PBM:Problem\+Investigation&qual='1000000232'=\%22%{ENV:TicketID}\%22 [NE,R,L]

    Required entry in the notification messages somewhere in the body text (example: Incident)

    blah-blah <a href="#HOMEURL#?showTicket=#Incident Number#">#Incident Number#</a> blah-blah

    # Short bypass for RSSO

    #RewriteRule    ^/arsys/login$           https://your_RSSO_server:8443/rsso/start?bypass-auth=true&tenant=your&goto=http://your_return_MT_server [R=303,L,NC]


    Special: adds context for calls without /arsys

    Use both files from the attachment as ROOT context under /webapps. I know there are other ways too, but now everything uses the same ootb technique


    Have fun!



    Remedy ITSM