URL Redirect Issue for legacy .cfm URLS


#1

We have experienced an issue when trying to setup URL rewrite rules in preside admin for legacy URLs that end in .cfm. URLs that end in index.cfm work without any problem, but anything else results in a blank page rather than redirecting as per the rules setup in the preside admin.


#2

Hi @nelson, this is an issue with your urlrewrite.xml file not rewriting .cfm files to /index.cfm. Right now, your rewrite looks like this:

<rule>
    <note>
        All request to *.html or ending in / will be rewritten to /index.cfm
    </note>
    <from>^(/((.*?)(\.html|/))?)$</from>
    <to last="true">%{context-path}/index.cfm</to>
</rule>

PresideCMS currently only processes requests for index.cfm so what you need to do in this case is add a rewrite rule for URLs ending in .cfm:

<rule>
    <note>
        All request to *.html, *.cfm (excluding /index.cfm) or ending in / will be rewritten to /index.cfm
    </note>
    <condition type="request-uri" operator="notequal">/index.cfm</condition> 
    <from>^(/((.*?)(\.html|\.cfm|/))?)$</from>
    <to last="true">%{context-path}/index.cfm</to>
</rule>

Once this is done, your Preside application will process any requests for .cfm URLs. Note, they will not attempt to invoke the template indicated by the URL and if you wanted to do that you would need to implement some kind of Route handler to deal with custom .cfm requests. However, Preside rewrite rules detecting *.cfm URLs will now work straight away.

Further note: when editing urlrewrite.xml on a local running Preside instance using CommandBox, you will need to restart your CommandBox site for the changes to take effect.


#3

Thank you Dom! Works perfectly after the change