I wonder how you had search friendly URLs already working on the other paths and only the search not working then?
However, I’m doing this not for you only, but also for the ones behind FarCry like @modius @justincarter and the rest of that team who are also great Lucee supporters (as well as of this forum) I did it also for myself for my own documentation, to help others and add some content to this issue here at the Lucee forum. This solution needs to have chelsea configured to have search friendly URLs enabled at webroot\farcry\projects\chelsea\config\_serverSpecificVarsAfterInit.cfm
with the setting <cfset application.fc.factory.farfu.turnon() />
.
Here is the working solution:
- Step: Create a server.json file with the following content and place it in your webroot to enable Tuckey:
{
"web":{
"HTTP":{
"port":4040
},
"rewrites":{
"enable":true,
"logEnable":true,
"config":"urlrewriteFarcry.xml",
"statusPath":"/tuckey-status",
"configReloadSeconds":30
}
},
"jvm":{
"javaVersion":"openjdk8"
}
}
Note: I’ve added a fixed port 4040 and the Java Development Kit for OpenJDK8 because I was having problems with Java 11 and FarCry.
- Step: Create a file named “urlrewriteFarcry.xml” in your webroot with the following content:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite use-query-string="true">
<rule>
<note>Generic Front-Controller URLs</note>
<!-- These are paths that don't exist on disk, but shouldn't get rewritten since the CF engine treats them special. -->
<condition type="request-uri" operator="notequal">^/(flex2gateway|flashservices/gateway|messagebroker|lucee|rest|cfide|CFIDE|cfformgateway|jrunscripts|cf_scripts|mapping-tag|CFFileServlet)/.*</condition>
<!-- This is a special URL that can be enabled with debugging -->
<condition type="request-uri" operator="notequal">^/tuckey-status</condition>
<!-- Used for the Adobe CF 2018 performance monitoring service -->
<condition type="request-uri" operator="notequal">^/pms$</condition>
<!-- Browsers like to send this request and it will get rewritten to /index.cfm/favicon.ico when it really just needs to be a 404 -->
<condition type="request-uri" operator="notequal">^/favicon.ico</condition>
<!-- Ignore any path to a .cfm or .cfml file in a sub directory that has a path info attached. These won't trigger as "real" directories below
since the rewrite filter doesn't know what part is the actual file name. Note, the ses path info servlet filter hasn't fired yet. -->
<condition type="request-uri" operator="notequal">^/.*\.cf(m|ml)/.*</condition>
<!-- This is a special URL that can be enabled with debugging -->
<condition type="request-uri" operator="notequal">^/search$</condition>
<!-- Do not rewrite paths that point to real files or directories -->
<condition type="request-filename" operator="notdir"/>
<condition type="request-filename" operator="notfile"/>
<!-- Turn localhost/foo into localhost/index.cfm/foo -->
<from>^/(.+)$</from>
<to type="passthrough">/index.cfm?furl=$1</to>
</rule>
<rule>
<note>Search URLs for FarCry CMS</note>
<condition type="request-uri" operator="equal">^/search$</condition>
<!-- Do not rewrite paths that point to real files or directories -->
<condition type="request-filename" operator="notdir"/>
<condition type="request-filename" operator="notfile"/>
<from>^/search\?q=(.*)$</from>
<to type="passthrough">index.cfm?type=dmSimpleSearch&view=displayPageStandard&bodyview=displayTypeBody&q=$1</to>
</rule>
</urlrewrite>
Note: Great part of the rules above are from default tuckey rules shipped by CommandBox, thus the biggest part of the credits goes to them and @bdw429s !
- Step: start the web application with CommandBox by opening a terminal session in your webroot and entering the command:
box server start
If you want to debug Tuckey, start instead CommandBox with
box server start --debug
and after the server has started, type:
server log --follow
That will enable tuckey status check in the URL and also output information to the console. To see the status of your tuckey, open the URL at: http://127.0.0.1:4040/tuckey-status
Note that I did not do deeper tests. But this may help you out and start looking around and debug tuckey url rewrite better.