1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SEO URL Rewriting

Discussion in 'White Hat SEO' started by prometheussoft, Oct 29, 2010.

  1. prometheussoft

    prometheussoft Newbie

    Joined:
    Jun 29, 2010
    Messages:
    41
    Likes Received:
    41
    Occupation:
    DBA
    Location:
    Kailua, HI
    Home Page:
    Let me get this out of the way before someone trys to point it out. I wrote this article for a job on Textbroker. This is the first one I've ever been able to find on the internet after the fact. Either way. Its still a relevant topic to discuss. I utilize it alot in my day to day operations of my sites. If you've gotten most of the basics down on a site, it might be time to take a look a url rewriting. Anyway, the rest is just a guide. If you need any help with it or have any questions let me know.

    *****Guide******
    SEO URL Rewriting

    Introduction:

    For the last few years most developers and site designers have been aware of the increased risk of using complex URLs. A complex URL tends to look something like http://www.somewebsite.com/apis/java?21f=9pump=true. This URL is a problem for both the user of the site and in some cases the search engine spiders have been known to stop when certain characters, such as ‘?', are read. Complex, or dirty URLs, are very common throughout the net. Sweeping changes in search engine practices and developer practices look to correct the problem through sophisticated URL rewriting techniques. URL rewriting seeks to simplify the URL and make the page look and feel more static rather than the dynamic dirty URL example above. Simplified URLs are not only easier for the user and the search engine, but in some cases can even be easier for the developers. URL Rewriting does however require some forward thinking and planning and some sophisticated rule based rewriters depending on the server environment you operate in. Some developers have written off the process simply due to its complexity but rest assured that the benefits far out way the time spent and efforts learning.

    Basic Tips and Tricks

    Before jumping straight into URL rewriting, try doing a few simple things to clean up a little before breaking the seal. The following list is in no particular order:

    1. Avoid punctuation in directory and file names. A lot of developers tend to use punctuation to the point of overkill in file and directory names and this can needless complicate site structures and maps.
    2. Keep it simple. Avoid difficult and descriptive directory names and instead opt for a more generalized directory structure. For example, if developing a site to sell fishing gear, instead of "/plasticbaits" use "/baits".
    3. Avoid common directory names. The use of common server side technology specific directories can not only complicate the URL but it can cause a security issue for the site. Avoid directory names like "/css" and "/cgi-bin" for something more generic.
    4. Avoid the use of query strings in urls. A lot of developers, especially with .NET and PHP technologies tend to use queries to drive an otherwise static page. For example, if a developer builds a website that allows a user to select a color, as a means to narrow down a search for used cards, often times URLS like http://www.somecardomain.com/pages/carsearch?=3 are generated. The idea is "3" is a primary key that drives a results list on the following page. The problem with this method is that in most cases the results page is otherwise static for the exception of the user driven query. In most cases it's much easier to pre-generate the page rather than waste precious resources generate the page dynamically. So this step is really a dual benefit.

    IIS and Windows Server

    For IIS, there is a module built by Microsoft for IIS7 with this specific purpose of helping administrators create rules based friendly clean URLs. For .NET developers it's a great opportunity to take advantage of IIS URL rewriting. This module or plugin which can be downloaded from the Microsoft website is great and has some impressive features. The IIS module can apply rules to analyze URL request in real time and rewrite them to a simpler version when requested. It can also utilize wildcard syntax for pattern matching which is extremely useful. IIS can use built in functions to manipulate strings and can convert URLS to lowercase and also perform their encoding and decoding.

    Basic Rules For IIS URL Rewriting - Block Access Rule

    A good example of IIS's URL Rewriting module is a block access rule. A block access rule in general is a good idea in preventing unwanted intrusion attempts on your site. Often times hackers tend to try and access your site or server by issuing HTTP request against the IP address of the server vice the host name. The first step in creating this rule is to edit the Web.config file of the site and insert the following code in the <rewrite> section.

    <rule name="Fail bad requests">
    <match url=".*"/>
    <conditions>
    <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
    </conditions>
    <action type="AbortRequest" />
    </rule>


    This rule in a nut shell has a couple of key sections. First, notice the <match url=".*"/> piece. This essentially says that any URL will match this rule. The next key section is the <add input="{HTTP_HOST}" pattern="localhost" negate="true" /> part. This section essentially checks to see if the host header is "local host".

    While this example is a specific URL rewriting scenario it does demonstrate the power of this feature. What it does demonstrate is the ability to monitor inbound requests and create a reaction based on the URL requested.


    SEO URL Rewriting with Apache URL Rewriting
    Apache URL rewriting is extremely complicated. Even the seasoned developers often find new sections of the mod_rewrite that they never knew existed. Mod_rewrite can essentially be the best friend of a developer as well as the worst enemy. The first step to using this system is creating a .htaccess file and placing it in the root directory of the website. One the file is created open it with a text editor and insert the following code;
    RewriteEngine on
    RewriteRule ^article/([0-9]+)/([0-9]+)/(.*?).html$ /article.php?articleid=$1&categoryid=$2

    Looking at each line individually, the first line tells the web server that the site will be rewriting the URLS and this keeps the server form throwing 404 errors. The next line tells the webserver when it encounters a URL that matches the rule it should complete the action defined. There are a couple of complicated Redex patterns being used in this example and some supporting information can be found at http://www.regular-expressions.info/.

    Step wise, the first step is to identify what is being looked for. In the above example ^article/([0-9]+)/([0-9]+)/(.*?).html defines what the serve is looking for. In apache it's important to always end this section with a dollar sign ‘$'. The next section defines the URL to be rewritten, in this case /article.php?articleid=$1&categoryid=$2. With Apache, it's really important to understand regular expressions which are something outside the scope of this article.

    The above example demonstrates the power of Apache URL Rewriting and the Apache webserver to recognize patterns and rewrite large groups of URLS.

    Java Applet URL Rewriting

    While there is nothing as straight forward as Apache mod_rewite and IIS URL Rewrite Module web based Java applets can also take advantage of URL rewriting. Most Java Applet URL rewrites must be accomplished through the use of third party plugins and filters. A good tool for Applets is the URL Rewrite filter which can work with any J2EE compliant web application server such as Orion or Tomacat. This plugin allows the developer to rewrite URLS before they hit the code through the use of xml files.

    Closing Thoughts and Remarks

    The above discusses methods are not the only alternatives for each platform and server side technology. There are a number of third party tools that offer to simplify the process of URL rewriting for the developer but they do come with a cost. The real question simply becomes is it more economically to learn the above methods or get a third party tool. There's no good answer to this as both methods work great.

    Make a consolidated effort as a developer to better organize and clean up the URLS of the sites you develop. URL rewriting will make a tremendous impact on your SEO campaigns. Remember that over fifty percent of websites traffic is from direct access, for example
    http://www.somedomain.com/. So making URLS that are easy to remember increases the chances the user will remember the sites URL.
     
    • Thanks Thanks x 1
    Last edited: Oct 29, 2010
  2. Say_Uncle

    Say_Uncle Newbie

    Joined:
    Oct 23, 2010
    Messages:
    20
    Likes Received:
    4
    Thanks for taking the time to post this information, I did lean a few new things from it.

    SU
     
  3. prometheussoft

    prometheussoft Newbie

    Joined:
    Jun 29, 2010
    Messages:
    41
    Likes Received:
    41
    Occupation:
    DBA
    Location:
    Kailua, HI
    Home Page:
    No worries. Glad to help.
     
    • Thanks Thanks x 1
  4. suskito

    suskito Newbie

    Joined:
    Sep 14, 2010
    Messages:
    20
    Likes Received:
    7
    It would be great if you could do this as a powerpoint presentation and then add your voice to it. Doing so will not only make it much more useful than what it is, but you will actually help more people.

    It is difficult to believe that 90% of most people will read such long post and remember at least 10% of it.

    Anyhow, good post.
     
  5. goodseoman

    goodseoman Power Member Premium Member

    Joined:
    Jul 1, 2010
    Messages:
    556
    Likes Received:
    247
    wow wow wow,
    this is really helpful for someone with basic coding knowledge.
    Thanks
     
  6. prometheussoft

    prometheussoft Newbie

    Joined:
    Jun 29, 2010
    Messages:
    41
    Likes Received:
    41
    Occupation:
    DBA
    Location:
    Kailua, HI
    Home Page:
    I may do that...I have a bunch of stuff like this from over the lsat few months...I might just make this a regular thing...once a week release a guide of somesort