Wildcard mapping for ASP.NET and issues with PHP

505 views Asked by At

I have an application written in .NET 3.5 with C# as the language. I'm using Web Forms, but using url routing with the routes defined in my global file. Everything is working as expected. In order for the pretty paths (see: user/665 instead of user.aspx?uid=665) to work properly, I had to add a wildcard mapping in IIS5.1 (local box, not test, staging, or production) the aspnet_isapi file for the 2.0 framework. Everything works fine.

Now, my site needs a plugin for PHP. However, the PHP files are now being serviced by ASP.NET due to the wild card mapping, and hence are not processed by the PHP interpretter. Is there any way to get around this? Would I have to add some sort of handler to my web app that will take all PHP requests being handled by the ASP.NET framework and have them routed to the PHP engine? Is there an easier way? Maybe a way to exclude them in the web.config (PHP files) and have them served by the proper PHP engine?

Thanks all! -Steve

3

There are 3 answers

0
Keith Adler On

The problem is that the PHP extension needs to be registered.

  1. In IIS Manager right-click on Default Website -> Properties -> Home Directory -> Configuration
  2. Under Application Mappings make sure that .php is added and is it pointing to PHP.EXE. There should be an entry like this: extension .php, executable path C:\PHP\PHP.EXE %s %s
2
Scott Arrington On

From what I gather, the problem is that ASP.NET is attempting to route your PHP requests, so what I would do is add a StopRoutingHandler() to your routes in the global.asax. Something like this should work:

routes.Add(new Route("{resource}.php/{*pathInfo}", new StopRoutingHandler()));

Edit: Be mindful that routes are processed in order, so I would add this to the top of your routes.

0
StephenPAdams On

This is a solution, but is not an elegant way (IMHO):

  1. Create a virtual directory
  2. Have it point to the folder with the files (in this case, a PHP plugin)
  3. Give it the proper permissions
  4. Change the config options for the virtual directory in IIS and make sure the wildcard mapping for that directory is removed.

This works like a charm for my situation. However, is there any way to not have to deal with virtual directories?