iis - URL Rewrite rules appear to be redirecting instead of rewriting -
i using iis url rewrite 2.0 module create url points latest version of app. have configured follows:
<rule name="latest" stopprocessing="true"> <match url="^latest(.*)" /> <action type="rewrite" url="1.1{r:1}" /> </rule>
the intention if goes /latest/*
of urls rewritten /1.1/*
. example /latest/index.html
should become /1.1/index.html
.
this working when request file, example:
/latest/index.html - works /latest/js/app.js - works
however not work:
/latest
since index.html
default document, expect rewrite /1.1/index.html
, in fact seems redirect. example, if type following in browser address bar:
http://<domain>/latest
and press enter, changes to:
http://<domain>/1.1
as if redirected. still works, don't want url change (hence why i'm using rewrite
rather redirect
). idea why? there wrong rule?
this problem you're experiencing:
iis generates courtesy redirect when folder without trailing slash requested
(although article iis6, iis7+ behaves in same way , seems can't disabled behaviour.)
add rule before existing 1 matches /latest
(no trailing slash):
<rewrite> <rules> <rule name="latest1" stopprocessing="true"> <match url="^latest$" /> <action type="rewrite" url="1.1/" /> </rule> <rule name="latest2" stopprocessing="true"> <match url="^latest(.*)" /> <action type="rewrite" url="1.1{r:1}" /> </rule> </rules> </rewrite>
there's more elegant way, says on tin.
you may need hard reload of page because browser may cache redirect, can test in "incognito mode" never saves permanent redirects between sessions.
Comments
Post a Comment