Routing Questions

So I recently converted a website. Built the whole thing out on my mac using Command Box and Coldbox. It has a lot of rewrites and special routing. Everything works great locally. When I update to my linux server none of the routing works. it sends everything to the front page. I tried putting in an htaccess with some of the recommended settings I found on line, still everything just gets sent to the front page. without the htaccess file I just get errors. Obviously I am missing something but even basic routes don’t work like domain/main/stats which goes to main.stats throws me to the front page. What are something things I need to look at?

Let me also add that I just uploaded the site from my local to my server. I did not install coldbox on the server directly just uplaoded everything. Maybe there is a setting in lucee I forgot? Although the front page loads so I know it’s working as far as serving up at least the front page files and layout.

Hopefully I’m explaining this right just trying to give as much info as possible.

Here’s my current route cfc just has a couple special routes

route(“/main/contact-us”).to(“main.contactus”);
route(“/journal/username/:username/”,“journal.index”);
route(“/journal/dream/:dreamid-numeric/username/:username/”,“journal.dream”);
route(“/journal/dream/:dreamid-numeric/”,“journal.dream”);

Then my OLD htaccess file
which I shoulnd’t need since it’s now all handled either via router.cfc or basic views

RewriteRule “^/?journal/dream/([^/]+)/user/([^/]+)/” “/journal/dream.cfm?dream_id=$1&username=$2”
RewriteRule “^/?journal/username/([^/]+)” “/journal/default.cfm?username=$1”
RewriteRule “^/?main/dreamsymbol/([^/]+)” “/main/definition.cfm?symbol=$1”
RewriteRule “^/?journal/user/([^/]+)” “/journal/default.cfm?username=$1”
RewriteRule “^/?journal/default/user/([^/]+)” “/journal/default.cfm?username=$1”
RewriteRule “^/?journal/friendsdreams/username/([^/]+)” “/journal/friendsdreams.cfm?username=$1”
RewriteRule “^/?main/results/keyword/([^/]+)” “/main/results.cfm?keyword=$1”
RewriteRule “^/?journal/dream/username/([^/]+)/dream_id/([^/]+)” “/journal/dream.cfm?dream_id=$2&username=$1”
RewriteRule “^/?journal/dream/dream_id/([^/]+)/username/([^/]+)” “/journal/dream.cfm?dream_id=$1&username=$2”

Based on some stuff I found online I did add this to my htaccess

RewriteRule ^$ index.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm?%{REQUEST_URI} [QSA,L,NS]

So that gets rid of errors but any link lands on the front page.

Also getting an error (via email) when I load a page that states
" TimeStamp: {ts ‘2023-10-31 12:28:25’}

Severity: 2

Category: coldbox.system.web.Renderer


renderview() has been deprecated, please update your code to view()"

Which seems odd since I just installed coldbox 2 weeks ago locally.

It sounds to me like your .htaccess rewrites are based on internet guides and not specific to ColdBox. Specifically this rule:

RewriteRule ^(.*)$ index.cfm?%{REQUEST_URI} [QSA,L,NS]

is taking all path information and sticking it in the query string in a format that ColdBox doesn’t expect.

You should be using this:

RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]

Take a look at the official ColdBox docs for using .htaccess rewrites:

As far as the “renderview() has been deprecated” issue, you likely used or found an out of date coldbox app template. In VS Code, you can do a Find and Replace across all documents to replace renderView() with view().

Unfortunately that didn’t work.
I am getting the following.
Messages: Page /views/main.fail.cfm [/home/zippy-navy-clematis/public_html/views/main.fail.cfm] not found

This is when i go to /main/fail

We’d have to see more of what you’re doing to determine why you’re getting that error. I wouldn’t automatically assume that error is due to an incorrect URL rewrite, though. It’s likely due to the renderView()/view() call using periods instead of slashes:

#view( "main.fail" )# <!-- INCORRECT -->
#view( "main/fail" )# <!-- CORRECT -->

i meant mydomain.com/main/fail
it’s coded properly with . not / I also switched renderview to view
Every URL I go to except the main page throws

No matching function [REDIRECT] found

Every single one. And it all works locally with no issue.

Well one of the changes worked it seems to be good to go now. Thanks for your help.

1 Like

Have another quesiton.
This url works
http://mydomain/members/themestats
but i also want
http://mydomain/members/themestats.cfm
to work. so it doesn’t mess up my SEO. Any idea how to accomplish that?

You’d probably want to strip .cfm file extensions when rewriting the URLs in your .htaccess file. Make sure you set a canonical meta tag so the two URLs aren’t indexed as totally separate pages.

This isn’t necessarily a ColdBox issue, for what it’s worth… although you can also accomplish this with a regex in the route config:

Yep thanks I saw your other reply as well. Appreciate it.

1 Like