Skip to main content
Owainnorth
Inspiring
September 30, 2010
Answered

404 Handler loses FORM scope

  • September 30, 2010
  • 1 reply
  • 1621 views

Howdy people, hoping someone can help me with this as I can't find anything previous.

Having only ever really written company internal systems, I've never really been that fussed about SEO. However I'm now working on a site where it's very important, so went about creating a handling page which would catch *any* page, figure out what you meant and using getPageContext().forward() to get the actual content. I've always known the theory behind doing so, but have never really gotten this far into the gubbins of it all.

Now what probably doesn't help is that I'm trying to be (maybe too) clever - I don't want Google and the suchlike flagging up "duplicate" content by having, for example, the site accessible by http://www.mysite.com/ and http://www.mysite.com/index.cfm. I appreciate that in theory this only requires me to not ever create links to the .cfm files, but sooner or later I will, or someone will figure one out, etc etc. Therefore I've tried storing all my .cfm pages *above* the web root, then using CF to get and include the content. Essentially, no pages actually exist (except the 404 page and 404 handler) - IIS routes all 404's to my CF handler page, as does my onMissingTemplate method (although this should never get hit if there are no .cfm pages).

However, I no longer have a FORM scope. Googling around seems to have revealed the issue - at some point recently IIS changed the way it calls your 404 handler - it now uses a separate thread to the original request, and so your submitted FORM values never get to CF.

So, my questions are:

1. Is there anything I can do about this? Have I jumped to the wrong conclusion?

or probably more sensible

2. Have I completely wandered so far down a dark pointless alley that I can no longer see the wood for the trees, and so have come up with a massively convoluted system which is far more complex than it ever needed to be?

I'd suspect the latter, but I'm sure I'm not the first person to want a site to work in this way. I apologise for a post on the boring old subject of SEO but hopefully this is a little more in-depth than the standard "how do I SEO my site" question. As I say I've got everything working - examining the URL, figuring out which page to go from an XML document and even translating the url into variables which I pass to the included pages. Everything works, except I have no FORM scope.

If anyone can point me in the right direction, I'd be most appreciative.

O.

This topic has been closed for replies.
Correct answer Adam Cameron.

Yep, well in that case it's def a job for mod_rewrite.

--

Adam

1 reply

Inspiring
September 30, 2010

2. Have I completely wandered so far down a dark pointless alley that I can no longer see the wood for the trees, and so have come up with a massively convoluted system which is far more complex than it ever needed to be?

I think you have.

However I'm now working on a site where it's very important, so went about creating a handling page which would catch *any* page, figure out what you meant and using getPageContext().forward() to get the actual content. I've always known the theory behind doing so, but have never really gotten this far into the gubbins of it all.

I'm not sure I quite follow.

Are you saying you're going to have a URL like http://www.owain.co.uk/some/path/to/a/file.cfm and you are going to 404-handle it, and redirect it to http://www.owain.co.uk/index.cfm which is then gonna look at the /some/path/to/a/file.cfm and work out that you need to include x.cfm, y.cfm and z.cfm etc?

You don't want to be doing that with a 404 handler.  You want to be doing it with mod-rewrite (or isapi_rewrite, or whatever).

Get the web server to route the SEO friendly URL to the correct CF-ready URLs.  don't get CF to do it.

--

Adam

Owainnorth
Inspiring
September 30, 2010

Hi Adam

Cheers for the reply, it's much appreciated.

No, I'm not saying I'd redirect /site/page/mypage.cfm to /myother/page/index.cfm, I'm saying for example that I'd redirect mysite.com/person/398473/dave-smith-barry/muppet/anything to mysite.com/person.cfm?personid=398473, ie being able to fill the url with any old SEO-friendly garbage I see fit.

I don't want *any* of my public URLs to contain .cfm preferably, because I think it looks a bit crap, especially if it's not at the end. However if they don't contain .cfm they don't get passed to onMissingTemplate(), hence no FORM scope.

Cheers

O.

Adam Cameron.Correct answer
Inspiring
September 30, 2010

Yep, well in that case it's def a job for mod_rewrite.

--

Adam