URL Rewrites not working and not sure what to check.

I’ve enabled url rewriting and selected a xml file for custom rules. Here’s my server.json:

{
“cfengine”:“lucee@5”,
“app”:{
“cfengine”:“lucee@5”
},
“rewrites”:{
“enable”:true,
“config”:“customRewrites.xml”
}
}

and my XML:

<?xml version="1.0" encoding="utf-8"?> ^/about$ /about.cfm

Does anything stand out? Hitting /about doesn’t load up my about.cfm page.

Hi Ray, your issue is that my docs were wrong on that! The actual rewrite config is supposed to be inside a “web” object like so:

{
“app”:{
“cfengine”:“adobe@10”
},
“web”:{
“rewrites”:{
“enable”:true,
“config”:“customRewrites.xml”
}
}
}

Or via the “server set” commands:

server set web.rewrites.enable=true
server set web.rewrites.config=customRewrites.xml

I just tested this and it works. Sorry for the confusion-- I’ll update the docs right now to make sure they all include the “web” bit in there.

Also, I noticed you had an extra cfengine property at the top level. It’s not hurting anything, but it’s extraneous. You can get rid of it with “server clear cfengine” (or just edit the server.json file!)

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Woot! Thank you. Quick follow up - 2 actually.

  1. We should expect to have to stop/start Box on every change, right? Or just changes to the server.json file?

  2. Using the rewrite in the XML you saw above, I can request /about, but in the browser, it shows /about.cfm. How do I prevent that? I want it to stay as /about

Ok, I believe I answered both questions. To keep the URL nice and clean, use passthrough for the type.

Also - I noticed that when I changed my XML, it was NOT updated in my Lucee server. That’s kind of annoying, but I can live with it I suppose.