Not exactly a CF thing. I have upgraded a CF appli...
# cfml-beginners
v
Not exactly a CF thing. I have upgraded a CF application (from Apache to IIS 10) with some removed functionality/Pages Task is to redirect the removed pages to some different URL (which I think can be only handled by IIS) e.g.
Copy code
<url 1> (deleted) when called should go to <url a>(Not in CF)
Copy code
<url 2> (deleted) when called should go to <url b>(In CF)
I checked the IIS redirect doc but there is no mention of URL to URL redirections https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/ is there a simple way which I am missing ?
p
Well depends what type of page it is; are you dynamically using a CMS that generates clean url pages aka index.cfm/myrandompage or are you referring to actual .CFM files being deleted?
v
Actual .cfm pages which are deleted
Also the url1 will be having parameters
Copy code
<https://abc.com/index.cfm?apple=1&ball=2>
r
You'll need to install the URL Rewrite extension if you want to do it with IIS. https://www.iis.net/downloads/microsoft/url-rewrite
j
Could you update the Application.cfc to use "onMissingTemplate" - https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onmissingtemplate.html ? plus see the note at the bottom about IIS
something like: function onMissingTemplate( required string targetPage ) { writelog(file="#this.name#",application = false, text = "#arguments.targetPage# does not exist."); origURL= listlast(cgi.path_translated,"\"); if (origURL == 'url1.cfm') { location("misstemp1.cfm", "false", "301"); } else if (origURL == 'url2.cfm') { location("misstemp2.cfm", "false", "301"); } else { location("missDefault.cfm", "false", "301"); } }
r
IIRC, URL Rewrite intercepts the request before it gets to CF so there are no issues as the note suggests in the Adobe article.
v
@Jim Frankowski: Thanks This was already configured as you mentioned Just need to add the if/else if
@Rodney: This is for sure the long term solution to handle with IIS Will work on it on the lower environment Thanks
e
The correct thing is at the SERVER request, to use a 301 redirect, you could do this with IIS, you oculd with every page go add a file, add 301 header and then point to the correct location or error code, or you could as above write a case, or cfif statement on request for the entire stack, chewing up some memory and making a mess or you could read the manual https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
j
I would use the IIS rewrites for global changes or whole directories and the cf missing templates for the edge cases