将动态网址转换为静态网址 [英] Convert Dynamic url to Static url
问题描述
你好,
我有一个动态网站,我想要它的SEO,为此,我必须将网站的网址从动态更改为静态.
我对代码进行了一些更改,然后将其转换为本地代码,但是当我将自己的网站上传到网络上时,它会产生错误; 找不到资源".
代码如下...
1)我在web.config文件中做了一些更改.
Hello,
I have a dynamic website and I want its SEO and for this I''ve to change my sites urls from dynamic to Static.
I converted the same with some changes in my code and it''s working for Local, but when I uploaded my site on web it''s generating an error; "Resource could not find".
Code is as follows...
1)I made some changes in web.config file.
<configuration>
<configSections>
<rewriter>
<rewrite url="~/Categories/(.+).html" to="~/Categories/default.aspx?CategoryName=$1" />
<rewrite url="~/CollectionSubCategory/(.+).html" to="~/Categories/default.aspx?subCategory=$1" />
<rewrite url="~/Collection/(.+)_(.+).html" to="~/SubCategories/default.aspx?SubCategory=$2" processing="stop" />
<rewrite url="~/Collection/zezadmin/products/(.+).jpg" to="~/zezadmin/products/$1.jpg" processing="stop" />
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
2-我在master.vb中做了一些更改
2- I made some changes in master.vb
Protected Sub generateNodes()
Dim myProductAdapter As New ProductsTableAdapter
Dim Categories As GetProducts.ProductsDataTable
'If (Not HttpContext.Current.User.Identity.IsAuthenticated) Then
' Categories = myProductAdapter.GetCategories()
'Else
' Categories = myProductAdapter.GetCategoriesAll()
'End If
Categories = myProductAdapter.GetCategories()
For Each categoryRow As GetProducts.ProductsRow In Categories.Rows
Dim subCategory As GetProducts.ProductsDataTable
subCategory = myProductAdapter.GetSubCategoryByCategory(categoryRow.CategoryName)
'Dim strLnk As String = "~/Categories/" + Replace(categoryRow.CategoryName, " ", "") + "_" + Replace(subCategory.Rows(0).Item("subCategory"), " ", "") + ".aspx"
Dim categoryNode As TreeNode = New TreeNode(categoryRow.CategoryName)
'Dim strLnk As String = "~/Categories/default.aspx?CategoryName=" + (categoryRow.CategoryName)
Dim strLnk As String = "~/Categories/" + categoryRow.CategoryName + ".html"
categoryNode.NavigateUrl = strLnk
lvCategories.Nodes.Add(categoryNode)
For Each subcategoryRow As GetProducts.ProductsRow In subCategory.Rows
Dim subCategoryNode As TreeNode = New TreeNode(subcategoryRow.SubCategory)
categoryNode.ChildNodes.Add(subCategoryNode)
''strLnk = "~/SubCategories/" + Replace(subcategoryRow.SubCategory, " ", "") + ".aspx"
strLnk = "~/Collection/" + Replace(categoryRow.CategoryName, " ", "") + "_" + subcategoryRow.SubCategory + ".html"
'strLnk = "~/SubCategories/default.aspx?SubCategory=" + subcategoryRow.SubCategory
subCategoryNode.NavigateUrl = strLnk
Next
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
generateNodes()
End If
End Sub
该代码适用于本地,但会为Web生成错误.
我还在bin文件夹中包含了Intelligencia.UrlRewriter.dll
.
我还有什么其他变化?
请告诉我...
谢谢与问候
Pooja Thakur
This code is working for local, but generating error for web.
I also included Intelligencia.UrlRewriter.dll
in bin folder.
What other changes have I to do?
Please tell me...
Thanks and Regards
Pooja Thakur
推荐答案
1" / < 重写 URL 〜/CollectionSubCategory/(.+).html" 到 =" 〜/Categories/default.aspx?subCategory =
1" /> <rewrite url="~/CollectionSubCategory/(.+).html" to="~/Categories/default.aspx?subCategory=
1" / > < 重写 URL 〜/Collection/(.+)_(.+). html" 至 〜/SubCategories/default.aspx?SubCategory =
1" /> <rewrite url="~/Collection/(.+)_(.+).html" to="~/SubCategories/default.aspx?SubCategory=
2" 处理 =" / > < 重写 URL 〜/Collection/zezadmin/products/(.+).jpg " 到 〜/zezadmin/products/
2" processing="stop" /> <rewrite url="~/Collection/zezadmin/products/(.+).jpg" to="~/zezadmin/products/
这篇关于将动态网址转换为静态网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!