These are my web.config rules:
<rule name="Remove Trailing Slash">
<match url="(.*)(/|\\)$"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<action type="Redirect" url="{R:1}"/>
</rule>
<rule name="anything" stopProcessing="true">
<match url="^(.*?)$"/>
<conditions>
<add input="{DOCUMENT_ROOT}/{R:1}" matchType="IsFile" negate="true"/>
</conditions>
<action type="Rewrite" url="/core/handler.php?url={R:1}"/>
</rule>
And these are my .htaccess rules:
# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)(/|\\)$ $1 [R]
# everything
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)$ /core/handler.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)$ /core/handler.php?url=$1&%{QUERY_STRING} [L]
They should behave the same, yet they don't, but I can't figure out what I'm doing wrong. I'm using the IIS rewrite module for my local website testing, but the server I'm hosting on uses apache and therefore .htaccess.
The point of this is to use stupidly complicated php handler to do all of the operations are usually done by the server (I would delve into the reasons but that's not the point of this question). The rules are written to rewrite the requested url so that the server serves the handler, which serves the correct content, while keeping the same face.
To summarise:
web.config:
input: http://local.com/folder_name
output: http://local.com/folder_name
internal: http://local.com/core/handler.php?url=folder_name
.htaccess:
input: http://server.com/folder_name
output: http://server.com/folder_name/?url=folder_name
internal: http://server.com/core/handler.php?url=folder_name
Any idea what went wrong?