Web.config file doesn't work in subfolders


#1

Recently, I did some restructuring on my website (WIP) and it required me to place all backend related stuff inside its own folder, let’s just call it “backend”.

This is the Web.config file I’ve been using so far:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="rule" stopProcessing="true">
          <match url="^" />
          <action type="Rewrite" url="/index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

It worked fine so far when I placed it inside the root folder of my server. But now, when I place this in the folder “backend” it doesn’t do anything. I get the typical answer of “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”.

Here’s what I’m trying to do:

  • anything that leads to the root folder and isn’t “example.com/backend” shouldn’t be treated in any special way
  • anything that leads to “example.com/backend” should be redirected to the index.php file inside the backend folder

How can I do this? Why is it not working when it’s inside a subfolder?


#2

This is by design by Microsoft and IIS. Web.Config files are specific to an application so if you want that folder to adhere to separate web.config file you need to make that folder an Application Directory. Create a new Virtual Directory under the Config tab of your CloudSite with the same physical folder name and mark as “Is Application”. If you have any questions or issues please let us know and we would be happy to help you. The best way would be to open a support ticket.