« Previous Next »

Thread: Use HttpNotFoundHandler for particular folder in IIS running php application

Last post 02-06-2009 2:24 AM by ksingla. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 02-02-2009, 2:41 AM

    • Entry
    • Not Ranked
    • Joined on 04-18-2005, 1:16 PM
    • Ahmedabad
    • Posts 1

    Use HttpNotFoundHandler for particular folder in IIS running php application

    Hi,

    I'm having an PHP application running on IIS7. I want to secure particular folder by modifying web.config. I don't want to use tag in config as this will redirect users to login page. Rather then, I'd like to implement HttpNotFoundHandler.

    Say for example, http://domain.com/SecureFolder is the directory on which I want to implement HttpNotFoundHandler. When user try to access that folder, the 404 page should be displayed.

    The secured folder can only be accessed via sub domain. Below is the config file which I'm trying to do the needful but that is not working. The IIS is having UrlRewrite module installed.

    <?xml version="1.0"?>
     
    <configuration>
       
    <connectionStrings />
       
    <appSettings />
       
    <system.web>
         
    <customErrors mode="RemoteOnly"></customErrors>
         
    <httpHandlers>
           
    <add path="~/securefolder" verb="*" type="System.Web.HttpNotFoundHandler" validate="true"/>
         
    </httpHandlers>
       
    </system.web>
     
    </configuration>
    Any help would be greatly appreciated. 

    Thanks in advance,

    Entry

     
     
  • 02-06-2009, 2:24 AM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 863

    Re: Use HttpNotFoundHandler for particular folder in IIS running php application

    You should rather use a location path to specify configuration for securefolder and then set a handler for path="*". Configuration will something like

    <location path="securefolder">
      <httpHandlers>
        <add path="*" type="... />
      </httpHandlers>
    </location>

    Also httpHandlers can only be used in classic mode for content mapped to aspnet_isapi.dll. If you want this to work for php running with fastcgi, you need to run application pool in integrated mode and use <handlers> section instead.

    Thanks.
    Kanwal

    Follow me on twitter at http://twitter.com/kjsingla
Page 1 of 1 (2 items)
Microsoft Communities