Tuckey rewrite rule to servlet in /app doens't work , bug?

57 views
Skip to first unread message

dile...@gmail.com

unread,
Jun 23, 2017, 11:40:10 AM6/23/17
to dotCMS User Group
Hi,

When I create a Tuckey rewrite rule for a servlet that is located under /app (for example /app/helloworld), the rewrite rule is not working.

But when I create another Tuckey rewrite rule for something outside /app, for example a file/image, the rewrite rule works.

I think there is a bug or something that prevents Tuckey rewrite rules to be applied to anything under /app.

I've created an example plugin which demonstrates this weird behavior.


Steps to reproduce:
1. Clone repo
2. Build the plugin with gradlew.jar bat (windows)
3. Upload to your dotCMS instance

Visit the page to check if the Hello World Servlet is registered - should be ok

Now try to visit the Hello World Servlet via the Tuckey rewrite rule, this won't work!
Rule created with addRewriteRule() method

Rule created with NormalRule class, won't work either

Now use Tuckey rewrite rule to forward to a file (image), this works...

Can someone please check why this is happenings?

Thanks.

Will Ezell

unread,
Jun 23, 2017, 11:43:20 AM6/23/17
to dot...@googlegroups.com
I think there is a servlet mapped to /app in the default dotCMS web.xml.  You will probably need to remove that. 

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/33bcf32f-c9bd-4ad0-8ecd-cd28286cd7ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--






3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

   

Maarten Daalder

unread,
Jun 23, 2017, 11:46:43 AM6/23/17
to dotCMS User Group
Hi Will,

But wouldn't that not be the Apache Felix servlet (that is bound to /app/*)?

The intention is to forward the request to a servlet that is added by the Dynamic Plugin.

With kind regards,
Maarten Daalder
ISAAC
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/33bcf32f-c9bd-4ad0-8ecd-cd28286cd7ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Tesser

unread,
Jun 23, 2017, 11:53:31 AM6/23/17
to dotCMS User Group
is it a redirect or forward 

Maarten Daalder

unread,
Jun 23, 2017, 1:54:13 PM6/23/17
to dotCMS User Group
We would want this to be a forward to prevent an extra request for CSS/JS.

dile...@gmail.com

unread,
Aug 21, 2017, 3:44:06 AM8/21/17
to dotCMS User Group
Hi,

Is there any update on this?

Thank you.

Op vrijdag 23 juni 2017 17:40:10 UTC+2 schreef dile...@gmail.com:

Nathan Keiter

unread,
Aug 21, 2017, 8:50:29 AM8/21/17
to dot...@googlegroups.com

We have been able to use Tuckey rewrite rules to override servlets in the /app/ folder in all latest versions. 2.5.4, 3.5.1, 4.0.1.

 

There is likely something wrong with your plugin.

 

Keep in mind after the rewrite, the original URL won’t work anymore.

 

So if your servlet is registered at “/app/funstuff”, “/app/funstuff” won’t work after mapping it to “/funstuff”.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Chris Falzone

unread,
Aug 21, 2017, 9:54:16 AM8/21/17
to dot...@googlegroups.com
This has been an issue since about version 3.6, any rule with the to type of "forward" does not work.


For example one of our rules for our blog was:

        addRewriteRule("^/blog/([A-Za-z0-9\\-]+)/?$", "/blog/post.htm?urlTitle=$1", "forward", "ContentStreamURLMap");

This is the workaround we were given:

        NormalRule rule = new NormalRule();
        rule.setName("ContentStreamURLMap");
        rule.setFrom("^/blog/([A-Za-z0-9\\-]+)/?$");
        SetAttribute cmsFilterUrlMapOverrideAttribute = new SetAttribute();
        cmsFilterUrlMapOverrideAttribute.setName("CMS_FILTER_URLMAP_OVERRIDE");
        cmsFilterUrlMapOverrideAttribute.setValue("/blog/post.htm?urlTitle=$1");
        rule.addSetAttribute(cmsFilterUrlMapOverrideAttribute);
        addRewriteRule(rule);

Which does the trick, but obviously, would like forwards to work properly instead of having to pass them through the CMS filter like this.

Will Ezell

unread,
Aug 21, 2017, 1:31:05 PM8/21/17
to dot...@googlegroups.com
Good news is that in the upcoming version of dotCMS, Vanity URLs are going to become content and respect regex based rewrite rules.  I can confirm that in the latest master this works:


Inline image 1


To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b86190bc-31d5-4a26-84f0-d7e8d822669e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c98980c1c68a4f84a55a2c7821730598%40exch13b.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--




Nathan Keiter

unread,
Aug 21, 2017, 1:37:54 PM8/21/17
to dot...@googlegroups.com

All of ours are type “forward” and they all work in the versions listed. (We have nearly 2 dozen.)

 

We’ve never had any environments on 3.6 however, but I can confirm it works in 4.0.1.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

Will Ezell

unread,
Aug 21, 2017, 1:43:17 PM8/21/17
to dot...@googlegroups.com
So, the current limitation on forwarding via tuckey will only apply if you are forwarding to a dotCMS page - not an external path or a struts/spring/servlet path.  If you are forwarding to page in dotCMS via tuckey, you will need to set the  CMS_FILTER_URLMAP_OVERRIDE value as Chris is doing.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b86190bc-31d5-4a26-84f0-d7e8d822669e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+unsubscribe@googlegroups.com.

To post to this group, send email to dot...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--




Nathan Keiter

unread,
Aug 21, 2017, 1:47:57 PM8/21/17
to dot...@googlegroups.com
For example, this Tuckey rule forwards "/createAlumnusAccount​" to "/app/createAlumnusAccount​".


[cid:28b82507-20cc-4a1f-bc59-ecdf9fc1c09b]


[cid:16af961c-e7e4-47c2-a2ea-245bcdbd6d46]


[cid:b1a5e7ef-5bbb-4406-832d-b9b4b9d83d8a]


dotCMS 4.0.1 (DEV)

[cid:2915cb06-4ee0-46a7-ab45-d8d35d330eb4]


dotCMS 3.5.1 (PROD)

[cid:9b6df33d-5f42-4094-be78-8ad3942de8fd]


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Nathan Keiter <nke...@gettysburg.edu>
Sent: Monday, August 21, 2017 1:37 PM
To: dot...@googlegroups.com
Subject: RE: [dotcms] Re: Tuckey rewrite rule to servlet in /app doens't work , bug?

All of ours are type “forward” and they all work in the versions listed. (We have nearly 2 dozen.)

We’ve never had any environments on 3.6 however, but I can confirm it works in 4.0.1.

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>

From: 'Chris Falzone' via dotCMS User Group [mailto:dot...@googlegroups.com]
Sent: Monday, August 21, 2017 9:54 AM
To: dot...@googlegroups.com
Subject: Re: [dotcms] Re: Tuckey rewrite rule to servlet in /app doens't work , bug?

This has been an issue since about version 3.6, any rule with the to type of "forward" does not work.

github issue: https://github.com/dotCMS/core/issues/9665

For example one of our rules for our blog was:

addRewriteRule("^/blog/([A-Za-z0-9\\-]+)/?$", "/blog/post.htm?urlTitle=$1", "forward", "ContentStreamURLMap");

This is the workaround we were given:

NormalRule rule = new NormalRule();
rule.setName("ContentStreamURLMap");
rule.setFrom("^/blog/([A-Za-z0-9\\-]+)/?$");
SetAttribute cmsFilterUrlMapOverrideAttribute = new SetAttribute();
cmsFilterUrlMapOverrideAttribute.setName("CMS_FILTER_URLMAP_OVERRIDE");
cmsFilterUrlMapOverrideAttribute.setValue("/blog/post.htm?urlTitle=$1");
rule.addSetAttribute(cmsFilterUrlMapOverrideAttribute);
addRewriteRule(rule);

Which does the trick, but obviously, would like forwards to work properly instead of having to pass them through the CMS filter like this.

On Mon, Aug 21, 2017 at 8:50 AM Nathan Keiter <nke...@gettysburg.edu<mailto:nke...@gettysburg.edu>> wrote:
We have been able to use Tuckey rewrite rules to override servlets in the /app/ folder in all latest versions. 2.5.4, 3.5.1, 4.0.1.

There is likely something wrong with your plugin.

Keep in mind after the rewrite, the original URL won’t work anymore.

So if your servlet is registered at “/app/funstuff”, “/app/funstuff” won’t work after mapping it to “/funstuff”.

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993<tel:(717)%20337-6993>
https://www.gettysburg.edu<https://www.gettysburg.edu/>

From: dot...@googlegroups.com<mailto:dot...@googlegroups.com> [mailto:dot...@googlegroups.com<mailto:dot...@googlegroups.com>] On Behalf Of dile...@gmail.com<mailto:dile...@gmail.com>
Sent: Monday, August 21, 2017 3:44 AM
To: dotCMS User Group
Subject: [dotcms] Re: Tuckey rewrite rule to servlet in /app doens't work , bug?

Hi,

Is there any update on this?

Thank you.

Op vrijdag 23 juni 2017 17:40:10 UTC+2 schreef dile...@gmail.com<mailto:dile...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b86190bc-31d5-4a26-84f0-d7e8d822669e%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/b86190bc-31d5-4a26-84f0-d7e8d822669e%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c98980c1c68a4f84a55a2c7821730598%40exch13b.ms.gettysburg.edu<https://groups.google.com/d/msgid/dotcms/c98980c1c68a4f84a55a2c7821730598%40exch13b.ms.gettysburg.edu?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgXaszYstE6oEf7GCyzhOBYrxdMm83MEPr9JQ%3Djok3evuw%40mail.gmail.com<https://groups.google.com/d/msgid/dotcms/CAMAbHgXaszYstE6oEf7GCyzhOBYrxdMm83MEPr9JQ%3Djok3evuw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/df8061ee9ae94e00a975556f73444a6f%40exch13c.ms.gettysburg.edu<https://groups.google.com/d/msgid/dotcms/df8061ee9ae94e00a975556f73444a6f%40exch13c.ms.gettysburg.edu?utm_medium=email&utm_source=footer>.

Nathan Keiter

unread,
Aug 21, 2017, 1:48:53 PM8/21/17
to dot...@googlegroups.com

Oh, ok.  I don’t think we have any “page” forwards.  Mostly servlets.

 

Thanks for the clarification Will.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Will Ezell
Sent: Monday, August 21, 2017 1:43 PM
To: dot...@googlegroups.com
Subject: Re: [dotcms] Re: Tuckey rewrite rule to servlet in /app doens't work , bug?

 

So, the current limitation on forwarding via tuckey will only apply if you are forwarding to a dotCMS page - not an external path or a struts/spring/servlet path.  If you are forwarding to page in dotCMS via tuckey, you will need to set the  CMS_FILTER_URLMAP_OVERRIDE value as Chris is doing.

 

On Mon, Aug 21, 2017 at 1:37 PM, Nathan Keiter <nke...@gettysburg.edu> wrote:

All of ours are type “forward” and they all work in the versions listed. (We have nearly 2 dozen.)

 

We’ve never had any environments on 3.6 however, but I can confirm it works in 4.0.1.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b86190bc-31d5-4a26-84f0-d7e8d822669e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.



 

--

 

 

 

 

 

 

3059 Grand Avenue

Suite 410-B

Miami FL 33133

Main: 305-900-2001 | Direct: 978.294.9429

 

   

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.


To post to this group, send email to dot...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages