FarCry Friendly URLs

Hello!

I would like to ask you if it’s possible to configure Lucee (urlrewrite.xml) and how according to Apache’s config instructions (mentioned here), in order to run FarCry URL friendly requests without a problem.

That would help me a lot!

Regards

Hi @asimkon

Yes it is possible

Install lucee with Apache using centos, rhel, debian or other using the lucees download script installer and follow the prompts.

After installation make sure you have the directive for your virtualhost or directory set to Allow Overrides. Finally add either ther .htaccess with the code you want mod_rewrite to run or enable it directory in the server configuration file.

I have already installed Lucee via Commandbox (URL Rewrites - CommandBox : CLI, Package Manager, REPL & More) on Windows OS and my query is if i could work entirely on Lucee by copying Apache config url directives to Lucee urlrewrite.xml using only tuckey syntax.

Regards

Apache Tomcat works differently than Apache HTTPD.

Short short answer, Not without modification, as the syntax is slightly different.

I would take a look at rewriting under Tomcat and convert accordingly.
https://tomcat.apache.org/tomcat-9.0-doc/rewrite.html

@Terry_Whitney because this is commandbox, there is no Tomcat in this scenario. CommandBox runs with the servlet container engine “Undertow” and here the Tuckey filter is used for urlRewrite.

@asimkon First thing I see is that FarCry is using a regex with a character set (inside of square brackets [ ] ), and I really don’t know why they are escaping lots of characters with the backslash in their rewrite rule: regex meta characters inside of character sets are different than outside as I told you already on my comment to your post on SO. However, if the team of FarCry post it as a working solution, then it should work with Apache2. Did you also try setting the rules for tuckey with the mod_rewrite-style-rules enabled? Then this plain rule as posted by the FarCry Team should work for Tuckey.

1 Like

Thanks for your reply!

I followed the rules from Far Cry team regarding friendly url for Apache .htaccess. Unfortunately the search friendly url problem still remains, despite the fact that I got an application update message.

Chelsea Boots theme

Regards

Could you please describe the problem that still remains a little? Any error? Any stack trace? Do you have any concrete example so we can try to reproduce it?

The problem has to do with HTML 404 status (/search?q=blabla) and unfortunately it’s not traceable via (?debug=1) as it returns no feedback at all.
If you try to install FarCry CMS 7.2.8 via Commandbox (embedded Lucee Server) according to these database instructions and of course Chelsea Boots, definitely you will run into this type of error.

Everything else works ok except the above one. I could post you all my project, but i have not done anything yet only just a simple installation of FarCry CMS. I have uploaded in my previous post thread the Chelsea Boots theme due to the fact that i am a new user.

Regards

Are you saying everything works ok? So all the other friendly urls are working normally and only the search above is not returning content?

Very sad to just find out in other cross posts of yours, that you have a longer thread about your issue here:

Sad is, that it has to be me who is sharing that very informative link to your issue, while we keep asking and asking.

Thanks for your reply and interest!

I just say that regarding this particular Chelsea Boot theme all the menu links work without problem except search request, MAYBE it is a friendly url issue MAYBE NOT, i am not sure. I think it would be better if you try and install it and see yourself what is happening wrong via commandbox (lucee embedded server).

Regards

Thanks again for your interest!

I have got a longer thread about my issue in FarCry technical support page, because NOT ALWAYS BUT USUALLY there are more possibilities to resolve that issue. Additionally there is ALWAYS an issue page in github open source project.
Besides i have also asked in Stackoverflow about that issue as soon as i realized it would be difficult to find a solution in FarCry github or respective forum and unfortunately they told me that it’s the wrong place. If you could install it yourself via Commandbox (lucee embedded server - Chelsea Boots), perhaps you could realize more things as more experienced user than me.

Regards

Question: does the following search link as you posted on your issue at the farCry discourse forum still work?

/index.cfm?type=dmSimpleSearch&view=displayPageStandard&bodyview=displayTypeBody&q=giant

If so, then I’d try to create a UrlRewrite rule to catch these search requests /search?q=giant and rewrite it to the working URL /index.cfm?type=dmSimpleSearch&view=displayPageStandard&bodyview=displayTypeBody&q=giant

Yes that menu link works fine at least for me and it catches (q) search requests. If you could create a custom Rule via customRewrites.xml, i would be delighted.

Regards

can you please post how your working customRewrites.xml looks at the moment and add it here as code?

I have not created a customRewrites.xml yet. I intend to add it to my project folder similar to .htaccess (does not work).

<?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>
    <!-- this will redirect the user from /foo to /index.cfm -->
    <rule>
        <from>^/foo$</from>
        <to type="redirect">/index.cfm</to>
    </rule>
    <!-- internally redirect the requested URL from /gallery to /index.cfm?page=gallery with query string appended -->
    <rule>
        <from>^/gallery</from>
        <to type="passthrough" qsappend="true">/index.cfm?page=gallery</to>
    </rule>

</urlrewrite>

And afterwards use this commandbox (hopefully not to have got any problem)
start --rewritesEnable rewritesConfig=customRewrites.xml

At this moment i have not had access to this specific project as i work away from home due to some unexpected reasons. I will be able to reply you wth more specific remarks from tomorrow.

If it works, you could post your reply to Stackoverflow and give you definitely full credit. I had had another issue with Lucee here.

Thanks a lot for your interest!

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:

  1. 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.

  1. 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&amp;view=displayPageStandard&amp;bodyview=displayTypeBody&amp;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 !

  1. 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.

2 Likes

Note, there is a cross post for this over on the Ortus Community Discourse forum as well. I’ve provided a Server Rule for basic Farcry rewriting over there:

1 Like

Thanks a lot for your interest!

I have uploaded the whole project (fresh copy of FarCry 7.2.8 along with MySQL db file). I think that it would assist you a lot and definitely save you from many hours towards the real cause of my problem.

Regards