Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2008, 08:39 PM
Authorized User
 
Join Date: Jan 2007
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default Implementing URL Rewriting

I did a post before regarding Search Engine Optimisation (SEO) using the TBH template.

A couple of things I implemented were a new MasterBase class that exposed the META Title and Description fields as overridable properties for content pages and also the ability to set default content for these properties within the Web Config file.

As someone pointed out at the time, another important thing with dynamic sites is URL rewriting.

There many reasons for implementing URL rewriting, one being to increase the search relevancy of your pages. Embedding keywords into your URL's and moving from using Querystring arguments to fully qualified URL's can often improve chances of your entire site being indexed and provide better ratings.

There are a number of httpModules available to provide URL Rewriting or you can relatively easily write your own. As time was an issue in my case and I wanted something reliable I used UrlRewriter.net (http://urlrewriter.net/). It is very easy to implement and if you are good with Regular Expressions you have all the flexibility you need.

In my case I simply wanted to my article links to display as "http://mywebsite.com/ARTICLE_TITLE_ID.aspx" instead of "http://mywebsite.com?ShowArticle?ID=71"

First I downloaded the binary from the above site and added Intelligencia.UrlRewriter.dll to the "bin" directory of my site.

Next I made the following additions to my web.config:

Between <configSections> & </configSections>

Code:
<section name="rewriter"
         requirePermission="false"
         type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />


Between <httpModules> and </httpModules>

Code:
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
Finally I added my rewriter expressions (anywhere in root of <configSections>):
Code:
    <rewriter>
        <rewrite url="~/([A-Za-z0-9-].+)_([0-9]+).aspx$" to="~/ShowArticle.aspx?ID=$2"/>
    </rewriter>


The ID of the article needs to be in the URL you are displaying somewhere so it can be passed back to the querystring. I would have liked to have my URL in the format:
http://mywebsite.com/ArticleID/ArticleTitle.aspx (i.e. .../71/Bits and Bobs.aspx) but I found that adding the extra "/" in my URL resulted in the pages not locating my .css file. Would be interesting to hear if anyone else has had this problem???

The regular expression above passes the number following the underscore "_([0-9]+)" as the querystring.

Once you have done this you can type in any text followed by an article to retrieve an article e.g. http://mywebsite.com/AnyTextIWantHere_71.aspx.

Now I just needed to change the URL's of the hyperlinks created by the ArticleListing.ascx control. Something I noticed first of all is that I would need to strip out the spaces of my article titles otherwise you end up with html space characters "%20" in your URL.

I changed my link to the below:

Code:
<asp:HyperLink runat="server" ID="lnkTitle" CssClass="articletitle" Text='<%# Eval("Title") %>' NavigateUrl='<%# "~/" & Eval("Title").Replace(" ", "_") & "_" & Eval("ID") & ".aspx" %>' ToolTip='<%# Eval("Title") %>' />
It's not the tidiest way of creating the URL but it works for now.

So now my article with title "Super Industrial Widgets" now has a hyperlink pointing to:

http://mywebsite.com/Super_Industrial_Widgets_71.aspx

which is not only more likely to give you higher page rankings but looks much better than:

http://mywebsite.com/ShowArticle.aspx?ID=71

Hope this is of some use.

For those people who have already implemented URL rewriting it would be great to hear how your methods.

Thanks,
Retro

 
Old January 8th, 2008, 08:03 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to vantoko
Default

Hi Retro,

I also played a while with the rewriter.
Now that you have implemented it, do you see any improvements in your ranking ?
do you manually adapt the web.config to manage the rewrites ?
wouldn't it be better to have a handler that looks into the DB and retrieves the ID associated with the given title ?

Have you read this thread where we already discussed the urlrewriter : http://p2p.wrox.com/topic.asp?TOPIC_ID=55144

koen




 
Old February 13th, 2008, 01:32 PM
Authorized User
 
Join Date: Jan 2007
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a quick update ref the above. As I wanted to achieve this with my categories also, I created a new property in the BLL Article and Category classes:

        Public ReadOnly Property Url() As String
            Get
                Return String.Format("~/a{0}_{1}.aspx", Me.ID, Me.Title.Replace(" ", "_"))
            End Get
        End Property

I can't really comment about whether this has improved page rankings as the site did not go *LIVE* until after the update.

However, having read up on how the search engine bots index sites, it should have some positive impact (although not as much nowadays due
to people abusing urls with keyword stuffing before)

I think just having friendly urls is worth the change i.e:

http://channelpumps.co.uk/a24_Series...obe_Pumps.aspx

looks so much better than

http://channelpumps.co.uk/ShowArticle.aspx?ID=24
Now that the above site has been live for a month now I have also seen a real benefit in the new MasterBase class I made that allows the article
pages to override the meta description field and page title.

Some results from Google demonstrate this. I just need to get the meta injecting working for the Category pages now:

Channel Pumps: Series D Rotary Lobe Pumps
Rotary Lobe Pumps for industrial and sludge applications SSP Series D ductile iron rotary lobe pumps fulfil postive transfer duties throughout industry ...
http://www.channelpumps.com/a24_Seri...obe_Pumps.aspx - 28k - Cached - Similar pages - Note this

Channel Pumps: Double Disc Pumps
For pumping media such as sludges, effluents and other wastes at flow rates up to 45 m3/h, throughout municipal and industrial treatment processes. ...
www.channelpumps.com/a26_Double_Disc_Pumps.aspx - 28k - Cached - Similar pages - Note this

Channel Pumps: Stainless Steel Rotary Lobe Pumps
Stainless Steel Rotary Lobe Pumps for industrial applications. SSP Series S stainless steel rotary lobe pumps fulfil postive transfer duties throughout ...
http://www.channelpumps.com/a28_Stai...obe_Pumps.aspx - 23k - Cached - Similar pages - Note this

Channel Pumps: Pumps handle Atex conditions
SSP Pumps has introduced Atex certified rotary lobe pumps for use in potentially explosive atmospheres under Atex directive 94/9/EC Group II, Categories two ...
http://www.channelpumps.com/a41_Pump...onditions.aspx - 21k - Cached - Similar pages - Note this

Retro


 
Old February 17th, 2008, 02:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When it comes to SEO, the biggest mistake people make is that there is no direct link to a given article from another page. A Bott will not try to post forms, and they typically only look at anchor tags. If you want your articles to be indexed you should include one page that has a big laundry list of articles as plain anchor links (it can come from the DB via data binding). And that page has to be found from an anchor at one of your main pages.

Also, and this is a biggie - the laundry list can not have paging because a Bott can't go to the next page. A form submit is needed to go to the next page and a Bott can't do that.

I'm told the Google bott can handle a single querystring variable but it doesn't like multiples. So the "?ID=24" is probably OK, provided the Bott has a way to find that link.

Eric

 
Old February 17th, 2008, 11:11 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
quote:Originally posted by englere


Also, and this is a biggie - the laundry list can not have paging because a Bott can't go to the next page. A form submit is needed to go to the next page and a Bott can't do that.
Not necessarily true...

http://www.eggheadcafe.com/tutorials...ging-with.aspx

 
Old February 21st, 2008, 01:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter provided a way to change your paging into clickable links that are search engine friendly. This is a workable option but requires a considerable amount of work.

You also need to realize what this will do with your bandwidth. If you're using a third-party hosted site, this can increase the bandwidth by a considerable amount. That's one reason I like WebHost4Life (unlimited BW).

Eric






Similar Threads
Thread Thread Starter Forum Replies Last Post
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
URL Rewriting Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 7 August 9th, 2007 01:54 AM
Disable the url rewriting in DotNetNuke 4.0.3 rskshiva General .NET 1 August 16th, 2006 01:17 PM
Discussion: URL Rewriting planoie ASP.NET 1.x and 2.0 Application Design 2 January 25th, 2006 03:38 PM
How to remove URL rewriting using tomcat config or mintnovate Apache Tomcat 0 November 13th, 2005 01:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.