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?