Httpd's ScriptMap for extensionless URLs - windows-ce

There is a way to configure the Windows CE HTTPD server, so that it will load some defined ISAPI Extension (e.g., asp.dll) for a defined file extension (e.g., ".asp").
What is the easiest way to make it load some ISAPI Extension for extensionless file names in URLs?

At the end I have not found another way to accomplish my goal, but to create a special ISAPI filter just for this. This is a simple ISAPI filter, that handles the SF_NOTIFY_URL_MAP server event and changes the pszPhysicalPath variable according to extension mapping settings. To make it a little more general, I made it to support not only mapping from extension-less paths, but to map from any to any extension. The mappings are set in Windows Registry.
How it works, basically:
A request gets to the HTTPD server, say to URL /vroot/file
The server maps /vroot/file to some physical path, say \disc\vroot\file
The server calls the filter with the physical path, and the filter maps it to, say, \disc\vroot\file.asp, according to it's settings.
The server then handles the file correctly with the asp.dll, according to the ScriptMap registry settings.
In case someone needs it, I've published the source code on GitHub.

Did you try to use "." as file estension? Never tried myself, it's just an idea.
Or you may use an ISAPI extension and re-define a whole virtual root, but this applies to all requests under that root, not just file names with no extension.

Related

Sending URL to ISAPI module in IIS

So I have an ISAPI module running my website. I would like to get the URL to be forwarded to my ISAPI module so that it can parse it and display things accordingly. For example, if I navigate to www.mydomain.com, I wish for my app to run. This does occur. However, I would like to navigate to www.mydomain.com/page1 and for my module to receive the "/page1" portion of the URL, which it does not. Rather, ISAPI complains because it cannot find the file "C:\where\I\have\my\app\deployed\to\page1".
I currently have my ISAPI module configured to run matching "/". If I configure it to run matching "*", it does not complain about not being able to find the file "page1" but instead treats anything I put into the URL as matching the module's request path and instead passes no URL information to the module.
I am uncertain what logs or settings would be useful to troubleshoot this issue.
ISAPI Filters are introduced in IIS 6, and not recommended any more since IIS 7. However, there might exists legacy code which needs to be maintained. So here is the guide to develop, troubleshoot and debug ISAPI Filters. But there is not a lot of documentation for this module to help.

Setting up existing site on dev server, how do I make "/some folder/file" direct to the application folder instead of the server root?

I have been given a zip file of an existing site to make some changes. All of the paths within the site use a path structure that starts with "/". In an environment where the site is mapped to a domain name, that is fine. However, when I drop the site into a folder on my development server which i reference like:
"//[myserver]/[thissite]/[index.cfm]"
I get constant 500 errors because every include or location reference looks at:
"//myserver/file"
This is probably a really simple issue to resolve but in my 20 years of developing sites, I have never had to deal with it as I always use links relative to the file instead of to the site root.
My first inclination was to just replace the links with relative links but with more than 800, it is not only impractical, but additionally, I can't change every page in the site. I am just supposed to fix the things that are broken.
My development server is running ColdFusion 11 integrated with IIS so the files are located in the "c:\inetpub\wwwroot\siteFolder"
I have tried:
Setting application mapping in an application.cfc file:
this.mappings[ "/" ] = expandPath("/siteFolder");
this.mappings[ "/" ] = expandPath("/siteFolder/");
this.mappings[ "/" ] = getDirectoryFromPath(getCurrentTemplatePath());
this.mappings[ "/" ] = getDirectoryFromPath(getCurrentTemplatePath()) & "/";
Tried setting up a new site in IIS:
Creating another website in IIS and binding it to siteFolder.myserver and myserver.siteFolder both of which resulted in DNS errors
I have also converted the folder to an application in IIS and still no difference.
I am thinking there might be a way to do it through url rewriting, but before spending more time on something that may not work, I thought I was ask for a little help to see if I was on the right track.
It sounds like your current process is to drop applications into subfolders of a single CF website on your IIS server. This will generally work as the presence of an Application.cfc in the subfolder will designate it as a new application with its own scopes, etc. As you've discovered however, it will mess with any absolute paths you may have in the templates.
Your best bet is to set this up as a new site in IIS. You need to set a binding up for it (I tend to use sitename.local) and you'll need to add that to your hosts file with the following format:
127.0.0.1 yoursite.local
Once this is done, you'll want to let IIS know that this is intended to be a ColdFusion application. ACF comes with the Web Server Configuration tool which should be in your start menu. (If not, you can find it in \runtime\bin\wsconfig.exe).
This will let you select which IIS sites are expected to use CFML and will set up the IIS connectors properly.

How do you specify a single IIS handler mapping path that applies to all URIs under a single subdirectory?

How can I configure a single IIS handler mapping path to allow all traffic starting with /rest/*, regardless of the number of subdirectories/subpaths, to be forwarded to ColdFusion?
Background: We run Lucee 4.5 behind IIS 8 connected with BonCode on our production environment. We are trying to implement our first of many REST endpoints using the native REST functionality in Lucee. As a result, all of our REST URIs begin with /rest/ even though this is not configured anywhere as a physical or virtual directory. I am able to add individual handler mappings to IIS in order to successfully pass traffic to specific subdirectories to ColdFusion.
The following are all examples of REST URIs and the associated handler mapping path that I had to add in order to get them to work. I would like to add a single handler mapping to encompasses them all.
REST endpoint: /rest/logout
IIS handler mapping path: /rest/*
REST endpoint: /rest/service/callback
IIS handler mapping path: /rest/service/*
(the first mapping path of /rest/* would not work for "deeper" subdirectories).
Is there a way I can specify "all traffic beginning with /rest/* regardless of the number of subdirectories"? It seems like there has to be a way to accomplish this without needing to add new entries for every new subdirectory that comes along ... ? Many thanks.
Found it. Apparently my search-fu was weak last weak when I posted the original question. I went looking again and found a solution!
How to register HttpHandler for all subfolders in Asp.Net?
In a nutshell you define a object in the web.config that maps to the subdirectory/URI (in my case, /rest), and then add a single wildcard handler to that location which handles all requests under that URI.

Redirect all HTTP-Requests with *.asp to one single file

Is it possible on an IIS to redirect all files with the file extension .asp to one single file (i.e. switch.php, switch.cfm) and how?
Thx in advance for the upcoming solutions :)
EDIT:
version of IIS is "IIS 6.0"
Here’s a few different thoughts off the top of my head:
Use an ISAPI filter. Either write your own or use a commercial one like Helicon ISAPI Rewrite (the reverse proxy feature should be able to do this).
Add a global.asa file to the root of the site and Response.Redirect to the page you want in the Session_OnStart event (I think this event still fires if the requested page doesn’t actually exist but am not 100% sure). More info here.
Define a new 404 “File not found” page in IIS which loads a custom page with a redirect to your desired URL. You could do this with either client or server side script and make it conditional on the requested URL having a .asp extension so as not to catch genuine 404s for other file types.
I’d say option 1 is your “best practice” approach but option 3 would get you up and running very quickly. Good luck!
your going to want to look into "iis modrewrite" on google :)
lets you use regular expressions to define rules and you can set a global match to rewrite to 1 page

Can IIS 6 serve requests for pages with no extensions?

Is there any way in IIS to map requests to a particular URL with no extension to a given application.
For example, in trying to port something from a Java servlet, you might have a URL like this...
http://[server]/MyApp/HomePage?some=parameter
Ideally I'd like to be able to map everything under MyApp to a particular application, but failing that, any suggestions about how to achieve the same effect would be really helpful.
You can set the IIS6 to handle all requests, but the key to handle files without extensions is to tell the IIS not to look for the file.
http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx
You can also create an ISAPI filter that re-writes urls. The user enters a url with no extension, but the filter will interpret the request so that it does. Note that in IIS it's real easy to screw this up, so you might want to find a pre-written one. I haven't used any myself so I can't recommend a specific product that's any different than what you'd find via google, especially as I don't know your specific use case. But at least now you know what to search for.
You can also rewrite your urls using ASP.Net:
http://msdn.microsoft.com/en-us/library/ms972974.aspx

Resources