2012-09-25 102 views
0

我有一個窗口託管Godaddy的靜態web應用程序。這將是什麼URL重寫規則?

在我的應用我有網址,象下面這樣:

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

而且我要重寫的網址是這樣的:

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

那麼,什麼將是網絡的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> 

在此先感謝。

+0

確實以下幫助? –

回答

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

你可能要考慮使用RewriteMap,所以你不需要寫出每個正則表達式。 – Dai

+0

我得到'500服務器錯誤... ... –

+0

我已經更新了答案。 – MWC

0

其實我不是使用.html擴展url重寫。我正在一期運用不extenssion URL重寫和URL你說我創建了一個規則,在我的項目,網址是低於

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

我認爲這將有助於你...

0

那麼如果你是使用asp.net和.NET版本4.0,你也可以在你的web表單項目中獲得RouteCollection的好處。

使用此功能,您可以輕鬆地將您的URL映射到特定的導航規則。

例如,在你的情況下,如果「微軟的雲CRM換小企業」是從任何表相同的名稱,你可以把下面的代碼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; 

並使用產品名稱獲取產品詳細信息。

這種方式可以使您的邏輯和正在渲染的頁面達到更好的代碼完整性。這是用於SEO的asp.net 4.0中的新東西之一。

can check爲更好的理解。

謝謝