FarCry friendly urls error

I have recently installed FarCry via Commandbox CLI (embedded lucee server), but unfortunately i get 404 http errors with friendly url requests. FarCry community officially supports Apache (.htaccess) and IIS for friendly url requests according to their guide.

Unfortunately at the moment i do not get any helpful stack trace errors in my Commandbox CLI. Is there any way to transform these rules into my embedded Lucee server (tuckey syntax) via customRewrites.xml (start --rewritesEnable rewritesConfig=customRewrites.xml)?

For more and detailed information there is already an open github issue.

Regards

Hi @asimkon ! Thanks for the post and the patience as I know you’ve been on several forums and ticket trackers at this point :slight_smile:

I’m not familiar with Farcry, but let’s focus on the specific rewrite rule farcry uses so we can find the equivalent for you. I have an idea I’m testing locally but I need to head out. I’ll reply back with details later tonight.

Please see my post at the Lucee Forum here:

@bdw429s never mind, I added a solution that should work. Just saw this cross post here. Hope you haven’t done much already.

@Andreas @asimkon Ahh, I was not aware this question had been cross posted either. I scan through the Lucee discourse topics, but I didn’t even realize from the title that CommandBox was involved so I hadn’t even read that other thread.

I see you have a possible Tuckey rewrite, but I’ll post my solution here since I think it’s cleaner :slight_smile: I used the Server Rules because they’re cool, generally less boilerplate, and can be specified right in your server.json (or an env var) without needing an additional XML file.

Now to the Farcry rules-- their documentation is a little confusing. They have at least 3 versions of their rule with different regex and I’m not sure which one is really necessary but I took the simplest example and created this rule which seems to work in my basic tests.

Put this in your server.json file and restart your server. No other custom configuration or files are needed:

{
    "web":{
        "rules":[
            "not regex('(^/farcry|^/webtop|^/flex2gateway|^/flashservices|^/cfide)($|/)') and regex('^([^\\.]+)$') -> { rewrite('/index.cfm'); set(attribute='%{QUERY_STRING}', value='furl=$1&%{BARE_QUERY_STRING}') }"
        ]
    }
}

Sorry it’s a little long with the two conditions. Technically this is similar to break it into two rules:

{
    "web":{
        "rules":[
            "regex('(^/farcry|^/webtop|^/flex2gateway|^/flashservices|^/cfide)($|/)') -> done",
            "regex('^([^\\.]+)$') -> { rewrite('/index.cfm'); set(attribute='%{QUERY_STRING}', value='furl=$1&%{BARE_QUERY_STRING}') }"
        ]
    }
}

but I don’t care for that solution since the done directive skips ALL REMAINING RULES including the “internal” rules CommandBox adds to secure sensitive files and block administrator access. So I generally don’t ever use done unless I’m specifically overriding a core rule, but I figured I’d show both approaches. done is the equivalent to last in mod rewrite.

And just for funsies-- when this ticket is fixed in Undertow (I’ve sent a pull) the rule above will be even simpler since I can finally set the query string as part of the rewrite.

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

I’m not likely to take time to actually spin up Far Cry unless, of course, you are interested in buying consulting hours/support from Ortus in which case I can dig into it at a deeper level. :slight_smile: But the rule above does seem to match what FarCry requires in my quick tests. You’re free to report back if you have issues, but I’m sure you can probably modify it from here to get it the rest of the way to what you need.

@bdw429s as always, CommandBox is full of beautiful surprises. Didn’t know that Server Rules. Great stuff!!!

1 Like

I understand and respect absolutely your job rules and of course your great assistance!

I would like to ask you if there is any way to connect my Commandbox embedded Lucee server application with an Apache HTTP server as my friend Andreas smartly and correctly says that Commandbox is full of beautiful and … unexpected “i would say” surprises.
If you could tell me step by step what to do to configure an Apache Server with Commandbox Server similar to this video as i do not use IIS.

I think that it would help me a lot and of course use FarCry’s friendly url Apache .htaccess on localhost 80 port.

Regards

You can sit any web server you want in front of CommandBox-- just configure a reverse proxy from the virtual host to whatever HTTP/AJP port CommandBox is running on. There’s really no reason to do that however since CommandBox has a powerful web server based on Redhat’s JBoss Undertow. You can choose the port as well if you want it on port 80.

server start port=80

And the best part is your ports, host, server rules, aliases, CF engine/version, JVM args, etc all go in one consolidated server.json file you can commit to your repo. This allows anyone else on any PC (Mac/Linux/Windows) to clone your repo and run server start and they get the exact same server with the same settings needing nothing more than CommandBox (no hard dependencies on XYZ web server installed or additional config files).

I’m not sure if you’re referring to the Server “Rules” above, or if you just mean my employer. To be clear, there’s no policy at Ortus preventing me from helping you further. I’m just aiming to teach you how to fish, not just give you all the fish. I’m not going to build your app for you, but I have given you the pieces you can basically copy and paste into your server.json file to get going. If you have more questions, that’s fine, but come back and tell us

  • what things you tried
  • what part didn’t work like you needed
  • what it is you need to be different

and we can try to help you further. There are people who just send me their code and say “Make this work for me”, but those are people paying support contracts :slight_smile:

For completeness: Alternatively to what @bdw429s already said, you can also try the following instructions from the Lucee Docs.

Brad already stated that using Apache2 is optional and I’d try Brads approach first. If Apache2 in front is necessary, please be aware that the tuckey rules or server rules we posted as a solution must not be configured. Then you need to do it within apache2.