I am implementing URL rewriting in my project. I added the rules for rewriting from IIS using URL Rewrite. Below is the code of my web.config file in which the rule is added:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<rewrite>
<rules>
<rule name="URLRedirect" stopProcessing="true">
<match url="^([a-z0-9/]+).aspx$" />
<action type="Redirect" url="{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
But the problem is i had written the rule for removing just the extension ie .aspx and i want my URL to look like
http://localhost:58370/URLRedirect/Default.
But now it is displaying it as http://localhost:58370/URLRedirect/
How can this issue be solved.....
Finally i was able to solve my problem of removing the .aspx extensions from my files. I wanted my URL to look like: http://localhost:58370/ShowPage
instead of http://localhost:58370/ShowPage.aspx
1)I added ShowPage.aspx page inside a folder named ShowPage. 2)And following are the rules that i added to my web.config file:
<rewrite>
<rules>
<clear />
<rule name="Redirect to clean URL" enabled="true" stopProcessing="true">
<match url="^([a-z0-9/]+).aspx$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="RewriteASPX" enabled="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.