Karthik N
Karthik N

Reputation: 535

How to call page name as folder instead of pagename.aspx

I am having pages like

domain.com/about.aspx
domain.com/photos.aspx

But I want like this

domain.com/about
domain.com/photos

Upvotes: 0

Views: 58

Answers (1)

Denys Wessels
Denys Wessels

Reputation: 17039

This is known as url re-writing in ASP.NET web forms and can be easily achieved by adding the following code to your Web.config file:

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="RewriteASPX">
          <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}.aspx" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

Upvotes: 1

Related Questions