Link to home
Start Free TrialLog in
Avatar of Grover McBroom
Grover McBroom

asked on

URL ReWrite configuration redirect all .htm to .cfm

We have Micrsoft's URL ReWrite installed on Windows Server 2012 R2 IIS 8.5, and wish to redirect system-wide any incoming traffic to any .htm file to be directed instead the corresponding .cfm file located in the same folder.  The .htm files existed previously but we can't seem to get .htm to work, even after changing the Handler Mappings and other CF Files others have recommended to edit.

The following  is not working for me. There is no  error but the .htm file which has ColdFusion code, does not process or redirect to the .cfm file. There are too may .htm files system wide to change easily.

I'm editing the web.config file directly because the IIS URL ReWrite is just far too alien for me.

What am I doing wrong in my code? Please only respond if you can see what I'm doing wrong and you believe you have a fix in the web.config file, or can show me exactly how to use the IIS 8  URL Rewrite Module to get this done.

This web.config file is in our web root directory and also where the .htm file is located we're testing.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
<rewrite>
     <rules>
  <rule name="htm to cfm" stopProcessing="true">
    <match url="(.+).htm$" />
    <action type="Redirect" url="{R:1}.cfm" />
  </rule>
</rules>
</rewrite>
         <defaultDocument>
            <files>
                <add value="default.cfm" />
            </files>
        </defaultDocument>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".cfm" allowed="true" />
                    <add fileExtension=".htm" allowed="true" />
                </fileExtensions>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

url rewrite isn't that smart.  I am guessing that you have a bunch of files you converted from .htm to .cfm but still have the url's pointing to .htm  

you had almost the same queston
https://www.experts-exchange.com/questions/28706616/Map-IIS-8-5-Coldfusion-11-to-process-htm-files-same-as-cfm-files.html in which you said the rewrite rules worked properly?

Your problem was that cold fusion wasn't being invoked with .cfm files
Which version of CF are your using?
Avatar of Grover McBroom
Grover McBroom

ASKER

You guessed right on the cfm / htm files.

Using CF11 Enterprise, licensed entered and all updates installed on Windows Server 2012 R2.

Can you show me how to do this in web.config example by modifying my code?
Do you need help with apache or IIS ? They both can do what you want.
This  is IIS version 8.5.
Does this help:
https://www.iis.net/downloads/microsoft/url-rewrite#additionalDownloads
Or if you really intend to change pages to not have htm, a trial of commercial apache htaccess parser is here for 45 days:
https://www.helicontech.com/ape/download.html
ASKER CERTIFIED SOLUTION
Avatar of Grover McBroom
Grover McBroom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Looks like that has already been done, not by me but someone else, okay by me.  Hope this is finally closed.