Yet another SES question (probably a simple one)

Hi all,

SES questions are probably one of the most common ones asked here, and I apologize if this has been answered a bunch of times before. I’ve checked the docs and I’ve looked here and I just don’t see what I am doing wrong.

I’m running CF9 with Coldbox 3.1 on a Windows server with IIS 7.

When I go to a url like this:

www.mysite.com/index.cfm?event=about.summary

everything works perfectly.

I am trying to set things up so that I can have SES URLs that look like this:

www.mysite.com/about/summary

So I have done the following:

  1. I’ve installed the URL Rewrite Isapi module on IIS and applied it to the site I am working on.
  2. I added the rules that I saw in the Coldbox docs. These rules are:
IterationLimit 0
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/.+/.+/.*\?.+\..*)$ /index.cfm/$1
RewriteRule ^(/[^.]*)$ /index.cfm/$1
  1. In my Coldbox config file, I’ve set up the ses interceptor like this:

{class=“coldbox.system.interceptors.ses”, properties={ configFile = “config/routes.cfm” } }

  1. In the routes.cfm file, I have setUniqueURLS set to true, and setAutoReload set to true (I’ve tried with both at default settings also). I also created a default route for mapping url calls to “/” to a specific handler/action, and that seems to work just fine.

So I think I have done everything correctly. But if I go to anything like this: www.mysite.com/handler/action I get a message saying that the page cannot be found. If I try going to the page like this:

www.mysite.com/index.cfm/handler/action

the page takes a while to resolve, and then just goes to the default landing page specified in my routes.cfm.

I’m sure I am missing something very simple. Thanks for any help!

Gary

Which ISAPI Rewrite have you installed, the ones you have posted look very much like .htaccess rewrite rules. Which means you would need the Helicon ISAPI rewrite module, or Helicon Ape.

Hi Andrew,

I believe I have the standard Microsoft ISAPI rewrite installed… I’m not sure how to check that. If that’s the case, do I need to get the rewrite rules from a different source?

Thanks,

Gary

In the full download package of Coldbox you will find an install directory, inside there you should find a web.config with IIS Rewrite rules.

Personally if you can afford it HeliconTech has the best rewrite ISAPI engine, as can also use the .htaccess files that Apache uses.

Ok, installing the web.config rules has eliminated the error messaging when I try to go to a url like this:

www.mysite.com/handler/action

But what is happening now is that any url I go to using the syntax above instead maps to the default event specified in the Coldbox.cfc config file. And I definitely have handlers/actions set up to match the URLs that I am testing.

Did you install the URL rewrite module? It isn’t installed in IIS7 by default.

Jason Durham

Hi Jason,

Yep, the module is installed.

Gary

I can’t access some of my CB code right now, but did you update routes.cfm to remove “index.cfm” from the base path (can’t remember the actual variable name)?

Does… http://www.example.com/index.cfm/handler/action work?

Jason Durham

Hi Jason,

No, that url structure doesn’t work either. The page takes quite a while to resolve, and when it does it just goes to the default event.

I did not make any changes to routes.cfm, as my understanding is that the removal of “index.cfm” from the base path is handled by the url rewrite module, but I could definitely be wrong about that.

If you are using IIS URL rewrite then your web.config needs to look something like this:

<?xml version="1.0" encoding="UTF-8"?>

Hi Jason,

I’m assuming you don’t mean the Mura-specific rule, just the “Insert index.cfm” rule below it. Yes, I have that rule in place already, as it was part of the web.config file supplied with Coldbox.

I’m really at a loss as to what I am doing wrong.

ColdBox doesn’t supply a webconfig that I know of.

It does.

It’s in the install\SES Rewrite Rules directory of the 3.1 package. It may only be in the full-download package though, not the “economy size” package, lol.

Good to know. I had sent one I knew worked. I just recently have the URL rewrite tool get corrupted. I will be uninstall and reinstalling tonight.

Jon,

Can you post the one that you have which works? I’ll give that a try.

Thanks,

Gary

Everyone,

I think I have success! I looked at some of the sample apps in the Coldbox install package and I saw this route:

addRoute(pattern=":handler/:action?");

I did not have this in my code and once I put this in, the pages started resolving correctly.

For anyone’s future reference, here’s what worked for me:

  1. With Windows/IIS 7 server I used the Microsoft URL Rewrite module.
  2. I put the web.config file provided in the Coldbox install package into the root of the site. Once that file is there, the URL rewrite module “sees” it automatically.
  3. I then made sure that the route above was in my routes.cfm file.

Thanks everyone for all your input and help.

Gary

I did. It was that Mura one. Mura portion is removed in the below.

<?xml version="1.0" encoding="UTF-8"?>

Oh, gotcha…sorry about that. :slight_smile: