asimkon
November 15, 2019, 4:57pm
1
I would like to add a url-pattern in Lucee 5.x (Tomcat) when visiting a specific url folder a particular script name will be appended at the end of this url folder. For example when i type http://localhost:8888/myApp/ * , the browser will be redirected to http://localhost:8888/myApp/hello.cfm/ *.
I tried to add the term /myApp/hello.cfm/* in url-pattern of Tomcat config/web.xml, but unfortunately there is no redirection to the appropriate web address. Any idea would be convenient to me !
Regards
andreas
November 15, 2019, 7:58pm
2
Hi,
I don’t understand very well what you are trying to do.
Should the URL location of your browser be redirected ( redirect 302 ) from (example here) http://localhost:8888/myApp/some-text--of-your-choice
to http://localhost:8888/myApp/help.cfm/some-text-of-your-choice
Or should it just be one call to:
http://localhost:8888/myApp/some-text--of-your-choice
and tomcat should just call under the hood with the new location (that means without redirecting 302 the browsers url?
And will help.cfm always be the same entry point, no matter what text is added to the last url pattern?
asimkon
November 15, 2019, 8:57pm
3
Tomcat should just call under the hood with the new location (that means without redirecting 302 the browsers url) and of course help.cfm will always be the same entry point, no matter what text is added to the last url pattern !
It is the only way to run the following example (Installation error · Issue #10 · cfwheels/cfwheels-example-app · GitHub )
as coldbox produces the first error on the screen. Is there any way to accomplish that or not?
Regards
andreas
November 15, 2019, 11:23pm
4
Setting up the servlet mapping in tomcats /conf/web.xml: is the first step only:
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
...
...
<url-pattern>/myApp/hello.cfm/*</url-pattern>
</servlet-mapping>
That was just to make that request point to Lucee. That means that after restarting tomcat the urls http://localhost:8888/myApp/hello.cfm/some-text-of-your-choice will be driven by lucee inside tomcat.
The second and still missing step is to add a urlRewrite-Rule for tomcat in order to get your URL
http://localhost:8888/myApp/some-text--of-your-choice
be rewritten to:
http://localhost:8888/myApp/hello.cfm/some-text--of-your-choice
That is also mentioned by neokoenig in the post you mentioned here:
As neokoenig posted there, follow the instructions posted by cfwheels-docs… see:A Brief Look at the Rewrite Valve in Tomcat 8 - A Blog By Tony Junkes
Your rewrite condition should be something like:
/conf/Catalina/localhost/rewrite.config
RewriteCond %{SERVLET_PATH} !-f
RewriteRule ^/myApp/(.*)$ /myApp/hello.cfm/$1 [L,QSA]
Further reading can be found directly at tomcats docs:
https://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
Hope that helps a little.
1 Like