URL Rewrite Filter

I tried to put the code but it was missing pieces.


Hi Debbie,
This looks good, except I would probably add a backslash to web-services in your “to” rule.

It’s not working.

Here is the old url: http://www.nsu.edu/webservices/index…

Here is the new url: https://www.nsu.edu/oit/operations/we…

Specifically, what coding would I use - and would the rule go under the or under the .

Also there is comments in the .xml with instructions:


in your web.xml add…

Does this mean take this coding and addit -which- specific region above?

I’ve been trying to get this to work but I am not familiar with this type of coding and any assistance is appreciated.

The Server Administrator placed the application and put the file in this location for me to edit: /Assets/redirect/XML-Redirects.xml

Would this also be correct?

Thank you again :slight_smile:

Hi Debbie,

It looks like you’re very close on this one. The rule for the redirect you have outlined would go under the opening tag, and would look like this:

<rule> <br>
   <from>/webservices/(.*)</from> <br>
   <to type="redirect">/oit/operations/web-services/$1</to> <br> </rule>

The placement and name of the URL rewrite filter XML file that you have described is not standard, but I assume your server admins made the required changes so that Tomcat will pick up this file once it has been approved and published. They can check the Tomcat log file, catalina.log, to quickly verify that your URL rewrite filter XML file is being picked up by the server.

One other reason this may not be working for you is because changes to this XML file will not be picked up by the server until you restart Tomcat. This could certainly explain why your rules are not working, if your server admins haven’t restarted Tomcat following the changes you’ve made to the file.

Got it working and a variation.

But I have one more question please…

We have events and they want to create a URL for this - which rule would I use and would it be case sensitive?

Thank you again - your responses are really enlightening.

We have a problem with our site where it’s not resolving unless users enter WWW for our address. Does anyone know if this can this be handled with URL Rewrite Filter, or is there a preferred option for taking care of this?


Ah I figured it out - thank you (it’s finally clicking!)

Debbie, I’m glad to hear it!

Brian, yes, a server level redirect routing non-WWW to WWW URLs is a common and recommended approach. From accessing your site just now over the non-WWW URL, it appears that you might have already successfully setup such a redirect – is that correct?

An alternate approach would have been to setup your site’s main virtual host to listen for requests coming into the sever over both WWW and non-WWW. Because you are running a Tomcat front end web server, that addition would be made using the Alias element. In your Tomcat’s server.xml file, a virtual host using the Alias element would look like this:

Oh I’m still having trouble with two and rewrote them but no luck.

These used to have meta refresh in blank pages - do you think that could be the reason?



Hi Debbie,

Can you quickly confirm that all of your previously working rewrite rules are still functional? One of my concerns for when your server team was setting this up was that they might add in the Filter rules to the web.xml located at {tomcat_root}/{my_site_apps}/ROOT/WEB-INF. The problem here would be that a full site publish would overwrite this particular web.xml file, causing your redirects to no longer function. More info on this is contained in our previous topic:


If your existing rewrite rules are still functional, please wrap your rules above in Code and Pre tags to ensure that I’m seeing the full syntax you’re using, like so:

 Rewrite rules go here.

Sorry - yes the others are working :slight_smile:

<rule> <br>
          <from>https://www.nsu.edu/blackboard/</from> <br>
          <to type="redirect">https://www.nsu.edu/sel/blackboard/index</to> <br>
<rule> <br>
          <from>https://www.nsu.edu/admissions</from> <br>
          <to type="redirect">https://www.nsu.edu/enrollment-management/admissions/index</to> <br>

Thanks for confirming that, Debbie. I’m guessing you were having issues with these rules in particular because the from and the to have matching patterns, causing a redirect loop (which is possibly why you added the full domain). The best way to setup these types of redirects (and a general good practice so that rules don’t conflict) is to open the from URL with a caret character, like so:

  <from>^/blackboard(.*)</from> <br>
  <to type="redirect">/sel/blackboard/</to> <br> </rule>   
<rule> <br>
  <from>^/admissions(.*)</from> <br>
  <to type="redirect">/enrollment-management/admissions/</to> <br> </rule>```

I’ll try this and thank you very much.

It sincerely helps when I know there is someone more knowledgeable in an area that can assist me in figuring out what I am doing incorrectly.

Looks like the redirects are working – glad I could help!

We have two domains that point to the same location:

spfldcol.edu & springfieldcollege.edu

Is there a rule that would allow me to route all traffic from spfldcol.edu to springfieldcollege.edu ?

Is there any danger in setting up a rule like this, if it exists?

Hi Brian,

This is actually very common. From looking over Tuckey’s site (http://tuckey.org/urlrewrite/manual/2…), I believe the rule would look like this:

  <name>Domain Name Check</name> <br>
  <condition name="host" operator="notequal">www.springfieldcollege.edu</condition> <br>
  <from>^(.*)$</from> <br>
  <to type="redirect">http://www.springfieldcollege.edu/$1</to> <br> </rule>```   
This should reroute all requests to your server via any domain name other than [www.springfieldcollege.edu](http://www.springfieldcollege.edu) (spfldcol.edu, spfldcol.edu, springfieldcollege.edu, etc.) to [www.springfieldcollege.edu](http://www.springfieldcollege.edu). I don't have an environment up and running to test this, so please proceed with caution and be ready to roll back in case this doesn't work.

This sounds good. We have a handful of rules in place that direct traffic to another server, and we do this by redirecting them to http://www3 (as oppossed to http://www )

I’ve placed one of these rules below. I would like to give your example a try, but do you think the example you provided would still work with rules like the one below in place:

<rule> <br>
   <from>/homepage/athletics.nsf/(.*)</from> <br>
   <to type="redirect">http://www3.springfieldcollege.edu/homepage/athletics.nsf/$1</to> <br>
   <set type="status">302</set> <br> </rule>   


Good catch, these two rules may very well conflict. I think what might work is ensuring that the rule above (redirecting to www3) appears above the global domain redirect, and then add a last=“true” property to the to element in the rule. According to the URLRewriteFilter manual, this will ensure that no more rules will be processed if this one is a match:


Again, I’m unable to test this to be sure, so be certain to back up the config file before modifying, to be sure that you can quickly revert back if there’s any trouble.