I set up htm/html/php rewrite & redirect based on this video, and it works perfectly except that it causes my php contact form to break on submit. Without the rewrite/redirect in place the form is submitted and the page is redirected (through action="index.php") to index.php, I then redirect it back to the contact page (demo.php) through "header(Location: demo.php). Once I enable redirect/rewrite the page redirects to "index" and then the form is never submitted nor does it redirect to demo.php. What setting/s do I need to modify to fix this?
The rewrite/redirect rules in my web.config file:
<rewrite>
<rules> <rule name="Hide .htm ext">
<match url="^(.*)" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.htm" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.htm" />
</rule>
<rule name="Redirecting .htm ext" stopProcessing="true">
<match url="^(.*).htm" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="(.*).htm" />
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Hide .html ext">
<match url="^(.*)" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.html" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.html" />
</rule>
<rule name="Redirecting .html ext" stopProcessing="true">
<match url="^(.*).html" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="(.*).html" />
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Hide .php ext">
<match url="^(.*)" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:0}.php" />
</rule>
<rule name="Redirecting .php ext" stopProcessing="true">
<match url="^(.*).php" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="(.*).php" />
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>
</rules>
</rewrite>
By changing the pattern="(.*).php" to pattern="demo.php" makes everything work, although it's not an ideal solution since it makes the .php rewrite/redirect only work for one specific page (i.e. demo.php).