SES and no index.cfm struggles

Hi,

I'm on CF 9 and IIS 7.

I've got SES working halfway the way I'd like it to work but I'd like
my URLS to not have the index.cfm in them. Currently, this URL works,
but you can see the index.cfm in it.

http://www.abc.com/index.cfm/store/product

I'm trying to not include the index.cfm part so I removed it from my
"Routes.cfm" file so it looks like this now but when I go to the new
url: http://www.abc.com/store/product, the page doesn't change, I just
see my home page, it's as if it's just getting ignored:

<cfscript>
  setEnabled(true);
  setUniqueURLS(true);
  if( len(getSetting('AppMapping') ) lte 1){
    setBaseURL("http://#cgi.HTTP_HOST#/");
  }
  else{
    setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/");
  }

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

Thanks

Because you need to activate a URL rewriter at the web server level. You cannot do this out of the box like that. You need to activate rewriting in your case via IIS7.

Hi,

Thanks for the response Luis.

I used the web.config file that is here:

http://blog.coldbox.org/post.cfm/coldbox-and-url-rewrites-with-iis-7

I just copied the code here into a web.config file which lives in the root of my site. When I open up IIS, I can see all the rules. I basically downloaded the IIS 7 rewrite module.

Does something need to be modified in this file?

all you need is this to do what you want to do:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="remove index.cfm" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}"
matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}"
matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.cfm/{URL}"
appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

all you need is this to do what you want to do:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="remove index.cfm" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}"
matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}"
matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.cfm/{URL}"
appendQueryString="true" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Thanks for the replies but the same issue still happens. When I click
a link the URL changes and it looks right, but the page itself doesn't
change. The URL looks right but the page doesn't load. I turned on
coldbox debugging and I think I can see the problem, I just don't know
how to fix it.

In the coldbox debugger, under "Coldbox Request Structures" I can see
that the event is NOT changing, so even though the URL is changing in
the browser, the actual value of the event variable is not changing.

Is there something else I need to do, maybe in the Routes.cfm file?

Hmmm... my advice would be to set up a new quick and dirty 1-page pure
HTML website in IIS with a simple test re-write rule and see if that
works first (basically de-couple from Coldbox and even CF) That way
you can tell if the issue lies with your IIS/Re-Write install or iod
CF/CB related.

I needed to do this just a few weeks ago: I could not for the life of
me figure out what was causing a lot of odd issues with my Coldbox
app. Eventually I narrowed it down to rewrites and specifically with
a bug in Helicon Tech's ISAPI ReWrite using the above technique. That
caused me to install the new rewrite engine 2.0 for IIS 7 and
basically I never went back to Helicon Tech. (By the way, I had used
their product and loved it for years and Helicon Tech forum moderators
believe they eventually figured out the bug, but by then I was happy
with the IIS app so I never reinstalled it.)

Makes sense. I looked at the ColdBox examples and the only example for SES contains index.cfm in the URL. This works fine for me, but my goal is to have it work without the index.cfm in the URL.

Did you have to make any special changes to your “Routes.cfm” file or and above what I posted in my first message?

I too am using the new rewrite engine 2.0 for IIS 7. I will keep trying and post back if I can find the solution.

Thanks for responding back…

My routes has this:

  // Base URL
  if( len(getSetting('AppMapping') ) lte 1){
    setBaseURL("http://#cgi.HTTP_HOST#/");
  }
  else{
    setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/");
  }

and my web.config is posted above. That's it, nothing more?

Yep, same here. I will try again. There must be something not right on my side. Stay tuned…

Thanks again!

If this hasn’t been said before you’ll also need a tag for your assets.

Yes, I have the base tag, but thanks. I found out I needed it right when my css and js includes weren’t working…and I think it’s mentioned in the forums here as well.