process files without .cfm extensions as coldfusion

bradderick
bradderick used Ask the Experts™
on
Howdy,

I have a dedicated windows server that currently hosts websites that are coded in .asp, .php and .cfm.

In addition, the server has a working coldfusion server.

All websites work fine, however, 2 of them are due to re-coded in coldfusion and they have .php and asp file extensions.

I would like to preserve the existing asp and php filenames and get them to execute as cold fusion files rather than as .php and .asp files. Each file will have all of the php and asp code stripped and purely have html & coldfusion code.

How can I get specific websites to interpret the .asp and .php files and process them through coldfusion. Note I do not want all .php and .asp files on the server to be processed as coldfusion, just the files on two websites.  I have had a problem before where all  php files were mapped to coldfusion and it made a lot of websites stop working.

Many thanks,

Brad
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

You have to make changes to CF config files and IIS

http://forum.hostek.com/showthread.php?92-How-to-set-htm-or-html-files-to-process-ColdFusion

the documentation will say .htm, but you would want .php, etc...

It seems that this can be done for a website because you go into a website settings, but I think it ends up being global for the server.   I set it up on one website, and it works on all... ! CAUTION !

Most Valuable Expert 2015

Commented:
(no points ...)

Maybe you could use some sort of url rewrite rules so it works more selectively (ie on some pages or sites, not all).  Unfortunately, I haven't done it so I don't know the details. But I *think* it might be possible.
I would definitely recommend using a URL Rewriter. If you are using IIS you can use ISAPI_Rewrite (http://www.isapirewrite.com/) or if you are using a Linux based web server they all have rewriting support.

RewriteRule (.*)/(.*)\.php(.*) /$2.cfm [I]

The rule above should work for what you want. Let me know if you have any difficulties.
Most Valuable Expert 2015

Commented:
Is that an expression for multiple sites?
If you want to redirect other extensions to cfm then just add more rules...

RewriteRule (.*)/(.*)\.php(.*) /$2.cfm [I]
RewriteRule (.*)/(.*)\.asp(.*) /$2.cfm [I]

etc...
Most Valuable Expert 2015

Commented:
No, my question was how to adapt that expression to *only* apply to particular sites, not all.  That's what the OP seemed to be asking :)
Just put the .htaccess in the root of the site that you want to redirect. The htaccess file contains the rules that apply to that site only.

Author

Commented:
thank you. appreciate the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial