I have some URLs as follows

  • http://localhost/wordpress/latest/joe/12
  • http://localhost/wordpress/latest/bloggs/14
  • http://localhost/wordpress/latest/thing/15

I would like to redirect them to

  • http://localhost/wordpress/file.php?id=12
  • http://localhost/wordpress/file.php?id=14
  • http://localhost/wordpress/file.php?id=15

So latest needs to be in the URL, then it could be anything, then a number

Any advice? I've tried this and although the test is fine, going to the URL doesn't work. I've even tried using a rewrite map but that doesn't work either.

By 'doesn't work' I mean the original URL stays on place.

<rule name="TEST" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="/wordpress/latest/(.*)/(.*)" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
  <action type="Redirect" url="http://localhost/wordpress/file.php?id=$2" appendQueryString="false" />

ReWrite Map

<rule name="ArticlesRule">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{Articles:{REQUEST_URI}}" pattern="(.+)" />
                    <action type="Rewrite" url="{C:1}" appendQueryString="false" />
                <rewriteMap name="Articles">
                    <add key="/wordpress/latest/dfjkdskfjdklsf/12" value="/wordpress/?id=12" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.