Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
HEU7Hwhu7

Any one know how to remove the extension like .HTML?

You have to nest it correctly

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite>  <rules>   <rule name="html rewrite">      <!--Removes the .html extension for all pages.-->      <match url="(.*)" />      <conditions logicalGrouping="MatchAll">     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />      </conditions>     <action type="Rewrite" url="{R:1}.html" />   </rule>  </rules></rewrite></system.webServer></configuration>

I think that is pretty close to correct, I am at work and cannot test it.

Recommended Posts

Posted · Original PosterOP

I'm making a website, and i was wondering how could i remove the .html at the end like this... I'm using IIS 10 Express for my server. 

Thanks. :)

Link to post
Share on other sites

For IIS you typically set it up in the web.config file (rewrite)

 

For apache you can set it up in the .htaccess file (mod rewrite)

 

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

 

Cheers.

 

 

-----------------------

 

Edit, unless you are talking about your root page(index.html, Default.html, etc) in which case you can just leave it out of the link

Link to post
Share on other sites
Posted · Original PosterOP

For IIS you typically set it up in the web.config file (rewrite)

 

For apache you can set it up in the .htaccess file (mod rewrite)

 

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

 

Cheers.

Thanks, i'm still learning html, and i'd like to do this, i'll give it a shot and if i have a problem, i'll tell you! :)

Link to post
Share on other sites

I'm making a website, and i was wondering how could i remove the .html at the end like this... I'm using IIS 10 Express for my server. 

Thanks. :)

If you have a local web server, you can just have multiple folders with an index.html file in the folders and it will look like this:

 

Home Page: myipordomain

Subpage: myipordomain/mypage


00110000 00110001 00110000 00110000 00110000 00110000 00110001 00110000 00100000 00110000 00110001 00110001 00110000 00110001 00110001 00110001 00110001 00100000 00110000 00110001 00110001 00110001 00110000 00110000 00110001 00110000 00100000 00110000 00110001 00110001 00110000 00110000 00110001 00110000 00110000 00100000 00110000 00110001 00110001 00110000 00110000 00110001 00110000 00110001 00100000 00110000 00110001 00110001 00110000 00110001 00110001 00110000 00110001 

Link to post
Share on other sites
Posted · Original PosterOP

For IIS you typically set it up in the web.config file (rewrite)

 

For apache you can set it up in the .htaccess file (mod rewrite)

 

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

 

Cheers.

 

 

-----------------------

 

Edit, unless you are talking about your root page(index.html, Default.html, etc) in which case you can just leave it out of the link

How would i do html? 

Link to post
Share on other sites

Something like:

<rule name="html rewrite">      <!--Removes the .html extension for all pages.-->      <match url="(.*)" />      <conditions logicalGrouping="MatchAll">        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />      </conditions>     <action type="Rewrite" url="{R:1}.html" /></rule>

Just create a web.config file in the same folder as your html file and add that to it.

 

IIS should look at the file before processing the request and adjust the url

Link to post
Share on other sites
Posted · Original PosterOP

Something like:

<rule name="html rewrite">      <!--Removes the .html extension for all pages.-->      <match url="(.*)" />      <conditions logicalGrouping="MatchAll">        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />      </conditions>     <action type="Rewrite" url="{R:1}.html" /></rule>

Just create a web.config file in the same folder as your html file and add that to it.

 

 

IIS should look at the file before processing the request and adjust the url

I get a

HTTP Error 500.19 - Internal Server Error 

  :(

 

Config Source:

1: <rule name="html rewrite">

2: <!--Removes the .html extension for all pages.-->

Link to post
Share on other sites
Posted · Best Answer

You have to nest it correctly

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite>  <rules>   <rule name="html rewrite">      <!--Removes the .html extension for all pages.-->      <match url="(.*)" />      <conditions logicalGrouping="MatchAll">     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />      </conditions>     <action type="Rewrite" url="{R:1}.html" />   </rule>  </rules></rewrite></system.webServer></configuration>

I think that is pretty close to correct, I am at work and cannot test it.

Link to post
Share on other sites
Posted · Original PosterOP

You have to nest it correctly

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite>  <rules>   <rule name="html rewrite">      <!--Removes the .html extension for all pages.-->      <match url="(.*)" />      <conditions logicalGrouping="MatchAll">     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />      </conditions>     <action type="Rewrite" url="{R:1}.html" />   </rule>  </rules></rewrite></system.webServer></configuration>

I think that is pretty close to correct, I am at work and cannot test it.

It works! :D thanks!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


×