URL Rewrite Filter

We are having an issue with redirects on tomcat using UrlRewriteFilter. Our goal is to have a vanity URL for our athletics website, while directing all incoming traffic looking for “/homepage/athletics.nsf” to our abbreviated domain www.spfldcol.edu. The two rules seem to conflict with each other, because the redirected URL ends up getting appended incorrectly. Any thoughts in terms of what we could do differently ?

/homepage/athletics.nsf/(.*)
http://www.spfldcol.edu/homepage/athl…
302

and the vanity rule set up like this:

/athletics
http://www.spfldcol.edu/homepage/athl…

Hi Brian,
Could you provide the syntax your using for the rule? You can paste the rules in a reply, just make sure you enclose them with these elements:

 Code goes here.
  
 <rule> <br>
<from>/homepage/athletics.nsf/(.*)</from> <br>
 <to type="redirect">http://www.spfldcol.edu/homepage/athletics.nsf/$1</to> <br>
  <set type="status">302</set> <br> </rule>   
  
 <rule> <br><br> <from>/athletics</from> <br><br> <to type="redirect" last="true">http://www.spfldcol.edu/homepage/athletics.nsf/home</to> <br><br> </rule>   
  

Hi Brian,
So your goal is to redirect all traffic coming to www.spfldcol/homepage/athletics.nsf to www.spfldcol/athletics/ ?

at this point we want all incoming traffic that has the string /homepage/athletics.nsf to go to www.spfldcol.edu/homepage/athletics.nsf/, as we will have spfldcol.edu pointing to a server that is not our cm1 tomcat server.

(all incoming traffic at our full url springfieldcollege.edu will be going to tomcat)

The first rule seems to be working as we are expecting, but when we include the rule for the vanity URL (it would like like www.springfieldcollege.edu/Athletics) the initial rule stops working, and we get an error.

Thanks Brian

Hi Brian,
I made of few tweaks to the syntax, adding starting and ending delimiters to /athletics in your second rule. Can you try this and let me know if this helps?

<from>/homepage/athletics.nsf/(.*)</from> <br>
<to type="redirect">http://www.spfldcol.edu/homepage/athletics.nsf/$1</to> <br>
 <set type="status">302</set> <br> </rule>   
<rule> <br> <from>^/athletics$</from> <br> <to type="redirect" last="true">http://www.spfldcol.edu/homepage/athletics.nsf/home</to> <br> </rule>   

This worked, thanks a million!

I have another question regarding rewrites.

We have mapped out where old URLs have new URLs on CM1. We seem to have two rules that in conflict and are wondering if there is any way to have them both working.

 
We would like users or crawlers that have indexed a sample page found here:   
 
/homepage/dept.nsf/BC81220B343BE6788525738E005FDA74/686EC96CBF7F0ABF85257A0E0068A400   
 
redirect to here:   
 
/giving-to-springfield-college/welcome-parents-families/faqs-for-parents/index   
 
We have attempted to implement this rule:   
 
<rule> <br> <from>^/homepage/dept.nsf/BC81220B343BE6788525738E005FDA74/686EC96CBF7F0ABF85257A0E0068A400$</from> <br> <to type="forward" last="true">/giving-to-springfield-college/welcome-parents-families/faqs-for-parents/index</to> <br> </rule>   
 
But we also have a more general rule that should be handling pages for which we do not have new content on CM1, and this rule seems to be superseding the rule listed above:   
 
<rule> <br>
<from>/homepage/dept.nsf/(.*)</from> <br>
<to type="redirect">http://mind2.spfldcol.edu/homepage/dept.nsf/$1</to> <br>
 <set type="status">302</set> <br> </rule>   
 

Hi Brian,
I think the problem has to do with the “to” type in your first rule. Is there a reason why it’s set to “forward” rather than redirect?

You are correct! That worked, thanks again!

The top example is a bit more complex than I think I need.

Here is what I am using:

We are using the same domain - but the old site was at: /webservices/ and the new one is at: /oit/operations/web-services

Is this correct?

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

/webservices/(.*)/oit/operations/web-services$1

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:

INSTALLATION

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?

Thanks!

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: