简体   繁体   中英

What will be the URL Rewriting rule for this?

I have a static web application on a windows hosting of Godaddy.

In my application I have URLs like below:

http://MyDomain.com/?page_id=18
http://MyDomain.com/?page_id=19
http://MyDomain.com/?page_id=20

And I want the Rewritten URLs to be like this:

http://MyDomain.com/microsoft-cloud-crm-for-small-business
http://MyDomain.com/online-development
http://MyDomain.com/small-development

So what will be the URL Rewriting rule in the web.config file..?

EDIT:

<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
    <rules>
    <rule name="Rewrite url" stopProcessing="true">
        <match url="^\?page_id=18" />
                    <action type="Rewrite" url="microsoft-cloud-crm-for-small-business" />
    </rule>
    <rule name="Rewrite url1">
        <match url="^\?page_id=21" />
                    <action type="Rewrite" url="Implementation" />
    </rule>
    </rules>
</rewrite>
</system.webServer>
<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
</system.web>
</configuration>

Thanks in advance.

<rewrite>
<rules>
<rule name="Rewrite url">
    <match url="^?page_id=18" />
    <action type="Rewrite" url="custom-development.html" />
    </rule>
</rules>
</rewrite>

Hi actually i am not useing a .html extenssion url Rewriting . i am useing a without extenssion url Rewriting and which url you are saying i create a rules for that url in my project it's below

<add name="test"  virtualUrl="^~/test-page/([0-9,a-z,A-Z,_,-]*)"
  rewriteUrlParameter="ExcludeFromClientQueryString"
  destinationUrl="~/test.aspx?cid=$1"
  ignoreCase="true" />

i think this will help you...

Well If you are using asp.net with .Net version 4.0 you can get benefits of RouteCollection in your web form projects as well.

Using this you can easily map your URL with particular navigation rule.

Eg in your case if "microsoft-cloud-crm-for-small-business" is identical name from any table you can put following code in global.asax...

 routes.MapPageRoute(
               "ViewPageDetail",               // Route name
               "/{*CategoryName}",  // Route URL
               "~/PageDetail.aspx"      // Web page to handle route
            );

And then in your page load you can have something like following.

string productName = Page.RouteData.Values["CategoryName"] as string;

and use the productname to get product details.

This way you can achieve better code inegrity with your logic and page that is being render. This is one of the new stuff in asp.net 4.0 for SEO.

You can check for better understanding.

Thanks

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM