Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:47:50+00:00 2026-05-29T05:47:50+00:00

I can’t seem to figure out how to create pages in CFWheels with clean

  • 0

I can’t seem to figure out how to create pages in CFWheels with clean URLs that contain “file” extensions.

I’d like to be able to do the following:

  • http://www.example.com/products.xml
  • http://www.example.com/products.json

As apposed to this:

  • http://www.example.com/products?format=xml
  • http://www.example.com/products?format=json

I’ve read through these docs but am still unclear about the actual implementation.

Lets say I have a controller (/controllers/Product.cfc) that looks something like the following:

<cfcomponent extends="Controller">

    <cffunction name="init">
        <cfset provides("html,json,xml")>
    </cffunction>

    <cffunction name="index">
        <cfset products = model("product").findAll(order="title")>
        <cfset renderWith(products)>
    </cffunction>

</cfcomponent>

How do I implement the view? Should it be views/products/index.xml.cfm?

<?xml version="1.0" encoding="UTF-8"?>
<products>
    <product><!-- product data goes here --></product>
</products>

How do I implement the routes.cfm?

I should note that I’m also using the default web.config and have <cfset set(URLRewriting="On")> in the config/setting.cfm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:47:51+00:00Added an answer on May 29, 2026 at 5:47 am

    Assumption about routes is correct. But you have to make sure rewriting works properly, say not partially. You can access urls like /controller/action, right? Not /rewrite.cfm/controller/action.

    So route definition can look like this:

    <cfset addRoute(name="indexProducts", pattern="products.[format]", controller="product", action="index") />
    

    In the index method you’ll have params.format populated with actual value, wich you want to validate (ListFind should work).

    View template for this page should have the name of its action: /views/product/index.cfm. Nothing special needed here unless you want to load views conditionally, for example separate view for each format. In this case you want to check out renderPage function. It can be used to override the default view.

    UPDATE

    OK, I’ve tested this solution and it wont work. Routes do not support anything except slashes as delimiter. So this kind of route can work only this way:

    <cfset addRoute(name="indexProducts", pattern="products/[format]", controller="product", action="index") />
    

    I guess we don’t want to modify CFWheels code (which is bad idea without further pull request any way), so I would recommend using web-server rewriting. For example, in Apache it may look like this:

    RewriteRule ^products\.(xml|json|html)$ product/index?format=$1 [NS,L]
    

    You are using IIS, so it should look similar to this (NOT TESTED):

    <rule name="Products listing" enabled="true">
        <match url="^products\.(xml|json|html)$" ignoreCase="true" />
        <action type="Rewrite" url="product/index?format={R:1}" />
    </rule>
    

    Think it’s better approach than trying to create controllers named like ProductsXml, ProductsJson etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one help me in sorting this out in sed/awk/perl Input file Start
Can anyone tell me how an IDE like NetBeans or any for that matter
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
Can I call select before recv_from on a socket that is blocking?
Can I have a project that has some parts written in c and other
Can some one confirm me that only one UIWindow instance is possible in any
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can anyone help me how to use the grails tags like g:select,g:label while creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.