Sunday, November 16, 2008, 11:59 PM Source Code by John (Article #229)
My current big project, starting to wind down a bit, is a redesign of the store website for GroundhogStuff.com. For those who don't read my blog much, I live in Punxsutawney, PA. Yes, the town with the groundhog. But, whistlepigs are not the topic -- stop distracting me!
This site has been running a ShopPal system for about four years and has accumulated several hundred products for sale during that time. We had to transfer all these products over from the old ShopPal system to the new custom system I built. Advertisements
Of course, because I am a geek, I slapped together a script using cURL to login to the existing ShopPal system, load the existing product pages from the admin, dump those into a browser and dump the browser stuff into files using ScrapBook. The reason for the browser fun is that ShopPal isn't particularly friendly to cURL, and seems to require a browser running before it will serve up many admin pages. There's probably a way to get around it, but the cURL + ScrapBook solution was what jumped into my mind the fastest.
So, once we have all these pages saved, I parsed them and dumped the contents into the MySQL database running the inventory system for the website.
But, I also wanted to preserve the old URLs and redirect them to the new sources.
Now, a ShopPal URL will go something like this one: /index.cfm/fa/items.main/parentcat/9099/subcatid/0/id/196629
Kinda cumbersome, right... So, I wrote a bit of code to parse the incoming URLs for the old ShopPal structure and redirect those, based on copies of the files from the admin, to the new URLs. If you click on the link above, you'll see that it dumps you to a kinda WordPress-y style mod_rewrite URL.
Now, here's the big thing to remember... if you want to keep your Google mojo, you gotta use a full 301 header to redirect GoogleBot to the new URL structure. 302s are bad, bad, bad.
So, for example, the underlying PHP code for this particular solution ends up being something like this:
header('Location: /shop/$cat/$id'.'_$atitle.htm',TRUE,301);
This lets GoogleBot know that the new URL structure is permanent and that it can here forward ignore that old URL.
More importantly, if preserving your SERP rankings in Google is important, the 301 is considered the one and only way to do the job. Google does not accept 302s to pass PR and SERP mojo, because that would allow people to game the system, as the 302ed page would still retain it's rank. In PR land, you got give something (the old URL structure's PR) to gain something (the new URL's PR).
It's as simple as that.
If you want a little bit more information, check out this article by Matt Cutts about 302 redirects and their general suboptimal-ness.
|
© 2012 Pro Content and Design. All rights reserved.
|
Tools
Check Google PageRank
Recent articles- Government cuts and tech spending
- What's the deal with Japanese web design?
- Did the July PageRank update come early?
- Servers handling "Pending Delete" .COM domains failing
- Photoshop CS5, first impressions
- Google PageRank toolbar updates coming today
- To Microsoft's credit
- Tracking expiring and dropping domain names
- GoDaddy finally cleans up its checkout process
- Back to basics: clean up your link names
Welcome!
Wonder where to start with your web design business?
This blog follows along with my efforts to build and grow a website design business, Pro Content and Design.
The goal of this blog is to fill in blanks that may be empty as you get your business rolling.
This blog, particularly the source code section, is not intended for beginners. If you are not comfortable with databases, Ajax, DOM objects and other advanced methods, I strongly suggest you go take a look over at W3 Schools before even reading -- let alone tinkering with -- any of the code here.
I hope this blog has some value to web designers as they attempt to get their businesses going.
Good luck, and happy reading.
Thank you,
John Crawford
Pro Content and Design

Books
I highly recommend Art of the Start if you have no idea where to start with marketing.
Links
Coding
W3 Schools
IBM's Mastering Ajax Series
Graphic Design
Worth 1000
Stock.XCHNG
Urban Fonts
Website Software
Apache Web Server
SquirrelMail
PHP/Zend
Website Design Issues
Non-Standard Character Guide
Google Trends
Search Engine Optimization Analyzer
Business
Guy Kawasaki's Blog
Seth Godin's Blog
Freakonomics
Computers
NewEgg
My Main Website
Pro Content and Design
Websites I have built
PunxsyPage: local free classifieds website
Groundhog Festival: for the local summer festival
My Webapps
TV Stations Transmitter Database
Google PageRank Checker
|