Question

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.

Était-ce utile?

La solution 3

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.

Autres conseils

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.

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top