开发者

What url rewriting or wildcard subdomain rule be followed in this given case?

I am totally new to URL Rewriting and WildCard Subdomain management.

My requirement is that I have a gridview in my ASP.Net 3.5 WebApp from where a hyperlinks navigate url property is dynamically generating the following url.

http://businessbazaar.in/BusinessBazaarAspx/Details.aspx?cid=1&name=Steel_Bird_Fabricators

Note : here _ denotes the white space between the words.

Now what I want is that when a user click on the url ,the browser wi开发者_如何转开发ll rewrite the url to

http://steelbirdfabricators.businessbazaar.in

I want it to achieve this via some dll or web.config. I don't want it on IIS as setting, Is this possible? Then please tell me how? It will be highly appreciated.


I'm assuming that somewhere in your gridview you have something like this:

<asp:TemplateField HeaderText="Url">
  <ItemTemplate>
    <asp:HyperLink ID="HyperLink1" runat="server"
                   Text='<%# Bind("CategoryName") %>'
         NavigateUrl='http://businessbazaar.in/BusinessBazaarAspx/Details.aspx?cid=1
                      &name=<%# Eval("CategoryName") %>' ></asp:HyperLink>
  </ItemTemplate>
</asp:TemplateField>

If you were to change that to something like

<asp:TemplateField HeaderText="Url">
  <ItemTemplate>
    <asp:HyperLink ID="HyperLink1" runat="server"
                   Text='<%# Bind("CategoryName") %>'
         NavigateUrl='http://<%# Eval("CategoryName") %>.businessbazaar.in/' >
    </asp:HyperLink>
  </ItemTemplate>
</asp:TemplateField>

Then that would solve the requested issue.

However this isn't going to deal with the implicit question - which is "How do I dynamically handle subdomains" - which is where your pain is probably going to start:

For this to work in IIS, you'll need a wildcard DNS entry set up, and then a dedicated IP address for the sites in IIS that you can map all these requests on to (it appears that IIS doesn't support wildcard host header entries).

You'll then need to set up something like the UrlRewrite IIS module or similar to handle the requests and work out what it actually needs to send to your application to get the correct information back to the user.

As a point of note, most SEO people will recommend against sub domains for permanent areas of your site as they carry less weight than pages/folders beneath the main domain. So you'd be better off taking the easier option of URLs such as: http://businessbazaar.in/steel-bird-fabricators (Note also the more SEO friendly use of hyphens to separate the words rather than underscores or mashingthemalltogther).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜