0

I'm attempting to 'prettify' my urls by getting rid of the .html url extensions. Upon researching similar questions, it seems a .htaccess file is require to change this, but all I have available with the particular server I'm hosting with is a web.config file. I do not know where to begin. Thanks in advance for any help.

Balint Bako
  • 2,500
  • 1
  • 14
  • 13
  • You could create a folder for every index.html, then you don't have the problem at all. Otherwise mod_rewrite or mod_redirect can help too. If you have an Apache HTTP Server... – Balint Bako Jun 07 '13 at 22:27
  • Web.config is IIS. .htaccess is Apache. This question has a link that details how to do what you want http://stackoverflow.com/questions/4124342/hide-extensions-of-the-pages-with-web-config – knoight Jun 07 '13 at 22:28
  • So I would just create a named folder, put my one index.html file in it, and it will still read the index.html file and get rid of the extensions? Sorry I'm kind of a newb. – Kyle Clay Richards Jun 07 '13 at 22:30
  • If you type `http://myserver.com/myuri` that will return `http://myserver.com/myuri/index.html` usually. At least this is the default on Apache and I assume the same for IIS. – Balint Bako Jun 07 '13 at 22:33
  • All of these suggestions make sense to me, it's just that my server does not allow me to edit the web.config file. Maybe I should contact them and have them help me too? – Kyle Clay Richards Jun 07 '13 at 22:42
  • 1
    @BalintBako Your first suggestion was the route I take to fix the problem. Thanks! – Kyle Clay Richards Jul 25 '13 at 17:25

3 Answers3

2

It seems that you are using an ASP.NET webserver. It is possible to add rewrite rules inside the web.config file. You define a url let's say http://myserver.com/helloworld and "redirect" it to the html file.

For example:

<system.webServer>
    <rewrite>
      <rules>
        <rule name="HelloWorldRewriteRule">
          <match url="helloworld$" />
          <action type="Rewrite" url="helloworld.html" />
        </rule>
      </rules>
    </rewrite>
</system.webServer>

In this case, all urls ending with helloworld would be redirected to helloworld.html. You can find a more detailed explanation here.

apparat
  • 1,930
  • 2
  • 21
  • 34
0

Maybe answer comes a little bit late but I had similar problem with static files and could not find an answer. IIS has a bug for static files and you need to apply a hotfix (if not applied yet) http://support.microsoft.com/kb/2646735

after that you need to add to your Web.Config system.webServer section

<staticContent>
    <mimeMap fileExtension="." mimeType="text/html" />
</staticContent>
0

I went with @BalintBako's solution above, and since it's not a comment I can't "accept" it as the answer. So here is the answer with credit to him.

I made a folder for each page (i.e. /about, /portfolio, /contact, /etc) and put an index.html file in each of those folders. This made it so you can reach those pages via direct link (webdomain.com/folder) and it would render the HTML that I have in the index.html file, therefore eliminating the .html extension for user friendliness. Pretty simple fix without any limitations from my knowledge.