0

I have created a Zurb Foundation html/css/js project as flat files using Sublime 2 as my text editor. I have setup local git and github for windows that I use to deploy to Azure websites. My html nav is below in a fiddle. What i want to do is create friendly url routing to remove the .html from the page name. Since the site only has 8 pages, I would like to do manually create/update the web.config file without having to use visual studio.

http://jsfiddle.net/setbon/smvdV/

Below is my web.config code which is in the root directory and is set-up to redirect the www. to the canonical domain without www, what rule do I need to add please so that the .html becomes an friendly url ?

Once more..I do not want to use have to use asp.net routing framework - it's just 8 pages so ... manually have the rule coded seems more efficient.

        <?xml version="1.0"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Canonical Hostname" stopProcessing="false">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
          </conditions>
          <action type="Redirect" url="http://{C:2}{REQUEST_URI}" redirectType="Permanent" />
        </rule>

        <rule name="Convert to lower case" stopProcessing="true">  
          <match url=".*[A-Z].*" ignoreCase="false" />  
          <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration> 
Julie S.
  • 127
  • 3
  • 18

1 Answers1

1

try looking these answers url:

Update:

Its works fine for static files:

        <rules>
            <rule name="Rewrite Rule">
                <match url=".*" />
                <conditions>
                    <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="{C:1}" />
            </rule>
            <rule name="Remove html Extension" stopProcessing="true">
                <match url="^(.+)\.html$" />
                <action type="Redirect" url="{R:1}" redirectType="Permanent" />
            </rule>
        </rules>
        <rewriteMaps>
            <rewriteMap name="StaticRewrites" defaultValue="">
                <add key="/file1" value="/file1.html" />
                <add key="/file2" value="/file2.html" />
                <add key="/folder/file3" value="/file3.html" />
            </rewriteMap>
        </rewriteMaps>

More info:

Community
  • 1
  • 1
  • tx. I pasted the code frm http://stackoverflow.com/questions/10210936/url-rewrite-remove-html-extension in my web.config and when I navigate to the site, the pages that were previously showing a .html the url now indeed no longer shows the .html but the whole site is now appearing as strict html and not showing any css styling - also now, with the exceptions of the home page - all the links now say "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." This is my web.config code: http://cropme.ru/aef47f95179e6f097af13e1641217f14 – Julie S. Jul 13 '13 at 17:25
  • Use the updated info in the answer, you only need add your static rules. – Alejandro Melis Fernández Jul 13 '13 at 18:05
  • @JulieS. you must change the rewriteMap keys and values with you own static filenames. If you want remove the HTML extension you need insert another rule. – Alejandro Melis Fernández Jul 14 '13 at 11:21
  • I want to remove the .html from every page. I was looking for a rule that would do it for all pages without me having to write my filenames. Is there one I could use ? – Julie S. Jul 14 '13 at 12:01