MilesWeb Hosting Forum

Please login or register.

Login with username, password and session length



SMF - Just Installed!

Author Topic: How to set redirection for non www to www URL in tomcat using UrlRewriteFilter  (Read 16160 times)

0 Members and 1 Guest are viewing this topic.

Offline Manish

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Hi All,

You can set redirection for non-www URL to www URL in tomcat using UrlRewriteFilter. Below are the steps to set redirection:

1) Download UrlRewriteFilter to WEB-INF/lib directory of your website.

2) Go to WEB-INF/web.xml and add below code (near the top above any servlet mappings):


3) Create file urlrewrite.xml in WEB-INF and add below code:

              <name>Domain Name Check for</name>
                <condition name="host" operator="equal">^</condition>
               <to type="redirect">$1</to>

Note: Replace with original domain name.

4) Restart tomcat service on the server.

That's all. Your website should now redirect from non www URL to www URL.
« Last Edit: December 03, 2021, 06:51:56 PM by pravinD »

MilesWeb Hosting Forum