Onpage SEO optimization for Dynamic Websites
This article I found during my research on web for Onpage SEO optimization for Dynamic Websites. Sharing this with my viewers to get the advantage of correct information in proper manner.
Please note that these examples are for *nix based web servers running Apache. If you have a Windows based web host running IIS, then this code won't help you.
EXAMPLE 1 - E-COMMERCE SITE
Sad Original URL = site.com/page.php?category=2&product=54
Happy URL :) = site.com/sandwiches/rueben-sandwich/
step 1:
Make sure that all category names and product names are unique in your database.
step 2:
Replace all references to Original URL with the New URL throughout your website.
step 3:
Use mod_rewrite in your .htaccess file to parse out the elements of the URL. Like this:
step 4:
Update your code on the page.php file to get the data from the database via the category and product name instead of by ID (this is why the names must be unique). For example:
EXAMPLE 2 - CUSTOM CMS DRIVEN SITE Here's another example. This is the way I manage the URLs on my custom CMS as described in my previous YOUmoz post.
step 1:
URLs can be absolutely anything you can dream up. Everything after site.com becomes that page's unique page_id.
site.com/section1/subsection/page-title/
site.com/blog/blog-section/blog-post/
site.com/about-us/
site.com/anything-you-want/does-not/matter-how/many/slashes-or-dashes/
step 2:
In your .htaccess file everything after the site.com domain name is going to be the unique page ID. So, I use this RewriteRule to pass it to the load_page.php file.
In load_page.php, I get all the content for the page from the database like this:
Hope this is helpful. Please note that this post has been written for a technical audience. I'll try my best to answer any questions posted in the comments.
Source: seomoz
Please note that these examples are for *nix based web servers running Apache. If you have a Windows based web host running IIS, then this code won't help you.
EXAMPLE 1 - E-COMMERCE SITE
Sad Original URL = site.com/page.php?category=2&product=54
Happy URL :) = site.com/sandwiches/rueben-sandwich/
step 1:
Make sure that all category names and product names are unique in your database.
step 2:
Replace all references to Original URL with the New URL throughout your website.
step 3:
Use mod_rewrite in your .htaccess file to parse out the elements of the URL. Like this:
RewriteEngine Onthe (.*) pulls the elements out and puts them in variables $1 and $2.
RewriteRule /(.*)/(.*)/$ page.php?category=$1&product=$2
step 4:
Update your code on the page.php file to get the data from the database via the category and product name instead of by ID (this is why the names must be unique). For example:
Before: "select * from database_table where categegory_id='$category' and product_id='$product'"NOTE: This is just a quick and simple example that doesn't consider sanitizing input for security (which you must do) or any table joins you might need to do on your site.
After: "select * from database_table where categegory_name='$category' and product_name='$product'"
EXAMPLE 2 - CUSTOM CMS DRIVEN SITE Here's another example. This is the way I manage the URLs on my custom CMS as described in my previous YOUmoz post.
step 1:
URLs can be absolutely anything you can dream up. Everything after site.com becomes that page's unique page_id.
site.com/section1/subsection/page-title/
site.com/blog/blog-section/blog-post/
site.com/about-us/
site.com/anything-you-want/does-not/matter-how/many/slashes-or-dashes/
step 2:
In your .htaccess file everything after the site.com domain name is going to be the unique page ID. So, I use this RewriteRule to pass it to the load_page.php file.
RewriteEngine Onstep 3:
RewriteRule (.*)/$ load_page.php?&page_id=$1
In load_page.php, I get all the content for the page from the database like this:
"select * from pages where page_url='".mysql_real_escape_string($page_id)."'";
Hope this is helpful. Please note that this post has been written for a technical audience. I'll try my best to answer any questions posted in the comments.
Source: seomoz
0 comments:
Post a Comment