[英]What will be the URL Rewriting rule for this?
我在Godaddy的Windows托管上有一個靜態Web應用程序。
在我的應用程序中,我有如下網址:
http://MyDomain.com/?page_id=18
http://MyDomain.com/?page_id=19
http://MyDomain.com/?page_id=20
我希望重寫的URL像這樣:
http://MyDomain.com/microsoft-cloud-crm-for-small-business
http://MyDomain.com/online-development
http://MyDomain.com/small-development
那么,web.config文件中的URL重寫規則是什么?
編輯:
<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>
提前致謝。
<rewrite>
<rules>
<rule name="Rewrite url">
<match url="^?page_id=18" />
<action type="Rewrite" url="custom-development.html" />
</rule>
</rules>
</rewrite>
嗨,我實際上不使用.html擴展url重寫。 我正在使用一個沒有擴展的URL重寫,並且您說的是哪個URL我在下面的項目中為此URL創建了一個規則
<add name="test" virtualUrl="^~/test-page/([0-9,a-z,A-Z,_,-]*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/test.aspx?cid=$1"
ignoreCase="true" />
我認為這將幫助您...
好吧,如果您將ASP.NET與.Net 4.0一起使用,則在Web表單項目中也可以獲得RouteCollection的好處。
使用此功能,您可以輕松地使用特定的導航規則映射URL。
例如,如果您的“ microsoft-cloud-crm-for-small-business”與任何表中的名稱相同,則可以將以下代碼放在global.asax中...
routes.MapPageRoute(
"ViewPageDetail", // Route name
"/{*CategoryName}", // Route URL
"~/PageDetail.aspx" // Web page to handle route
);
然后在頁面加載中,您可以看到以下內容。
string productName = Page.RouteData.Values["CategoryName"] as string;
並使用產品名稱獲取產品詳細信息。
這樣,您可以使用正在渲染的邏輯和頁面來實現更好的代碼完整性。 這是asp.net 4.0中針對SEO的新功能之一。
您可以檢查以獲得更好的理解。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.