简体   繁体   English

URL重写规则是什么?

[英]What will be the URL Rewriting rule for this?

I have a static web application on a windows hosting of Godaddy. 我在Godaddy的Windows托管上有一个静态Web应用程序。

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: 我希望重写的URL像这样:

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..? 那么,web.config文件中的URL重写规则是什么?

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 . 嗨,我实际上不使用.html扩展url重写。 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 我正在使用一个没有扩展的URL重写,并且您说的是哪个URL我在下面的项目中为此URL创建了一个规则

<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. 好吧,如果您将ASP.NET与.Net 4.0一起使用,则在Web表单项目中也可以获得RouteCollection的好处。

Using this you can easily map your URL with particular navigation rule. 使用此功能,您可以轻松地使用特定的导航规则映射URL。

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... 例如,如果您的“ microsoft-cloud-crm-for-small-business”与任何表中的名称相同,则可以将以下代码放在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. 这是asp.net 4.0中针对SEO的新功能之一。

You can check for better understanding. 可以检查以获得更好的理解。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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