0

I have a website on azure, and I am trying to make some user-friendly urls to my websites use.

I have downloaded IIS remote manager, and did as it was explained here. Although the article is since 2008, the GUI of the remote IIS manager is still almost the same.

after defining the rewrite map, and the rule that looks inside the map, this is the web.config that was generated:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rewriteMaps>
                <rewriteMap name="StaticRewrites">
                    <add key="/niceurlpart" value="/Menu/master/#/Menu?Token=7926983e-c64e-4547-85f5-d85e3c06c7a8" />
                </rewriteMap>
            </rewriteMaps>
            <rules>
                <rule name="Rewrite rule1 for StaticRewrites" patternSyntax="ExactMatch">
                    <match url=".*" />
                    <conditions>
                        <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

when I enter inside the address bar: mydomain.com/niceurlpart I get: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

Also, when I try to test the pattern inside the remote IIS manager, it fails..

am I missing something?

HS1
  • 608
  • 2
  • 10
  • 28

1 Answers1

0

Not sure on the syntax of doing this in web.config, but the # part of a URL doesn't reach the server, so using that in your rule won't work.

If you are using angular type app and are using # for routing, then try using HTML5 mode which will get rid of the hash.

If your are after SEO, you can google '_escaped_fragment_' to get the hash value to your server. Also if SEO is your goal then we use _escaped_fragment_, along with this tool https://prerender.io

Daniel van Heerden
  • 836
  • 1
  • 7
  • 25
  • Hi, yes, the syntax is for angular. – HS1 Aug 27 '15 at 05:30
  • . The thing is that my original my key=/niceparturl is not angular and without #, so it should go to server I think, and then the value should point it to its different url – HS1 Aug 27 '15 at 05:39
  • OK, can you explain your use-case to me? It doesn't feel like a standard single page application implementation? – Daniel van Heerden Aug 27 '15 at 07:02
  • I have a website written as SPA in angularjs: mydomain.com/Menu/master/#/Menu?Token=7926983e-c64e-4547-85f5-d85e3c06c7a8" I don't want the user to write the whole URL to access my website. I just want hime to write: mydomain.com/prettyurl, and the server will send him to "mydomain.com/Menu/master/#/Menu?Token=7926983e-c64e-4547-85f5-d85e3c06c7a8" – HS1 Aug 27 '15 at 07:14
  • OK so just for a landing URL? You can also just redirect them in your global.asax which should be very simple. Your server may be missing the rewrite module. – Daniel van Heerden Aug 27 '15 at 09:04
  • If you are sure you want to use the rewrite module, try getting it working locally and make sure you install the rewrite module on your local machine. Then at least when you push it to the server you'll know it isn't something you are doing wrong. – Daniel van Heerden Aug 27 '15 at 09:05