**Dependencies**: I'm running a WordPress site on an Azure App Service.

**The Goal**: If anyone visits :

`example.com/my-page.php`

They are then redirected to:

`example.com/my-page/`

OR (without the backslash):

`example.com/my-page`

I've looked all over StackOverflow to find a solution, but nothing has been WordPress/Azure specific, and hence didn't work.

The answer is simple via Apache and an `.htaccess` file:

```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

```

But when I try to edit the `web.config` file with anything other than what WordPress declares as the default redirect, things get tricky.

Here's what I currently have in my `web.config`:

```
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WordPress: https://example.com" patternSyntax="Wildcard">
          <match url="*"/>
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            </conditions>
          <action type="Rewrite" url="index.php"/>
        </rule>
        <rule name="hide .php extension" stopProcessing="true">
          <match url="(.*)" />
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
          <action type="Rewrite" url="{R:1}.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

```

The first rule forwards all requests through `index.php` for WordPress. The second rule was something I found online to help convert all requests ending in `.php` to non-extension URLs. It doesn't work.

Does anyone have a working solution for this particular situation?