Wrox.Professional.Search.Engine
Total Page:16
File Type:pdf, Size:1020Kb
00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page iii Professional Search Engine Optimization with PHP A Developer’s Guide to SEO Jaimie Sirovich Cristian Darie 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page ii 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page i Professional Search Engine Optimization with PHP 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page ii 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page iii Professional Search Engine Optimization with PHP A Developer’s Guide to SEO Jaimie Sirovich Cristian Darie 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page iv Professional Search Engine Optimization with PHP: A Developer’s Guide to SEO Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-10092-9 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data: Sirovich, Jaimie, 1981- Professional search engine optimization with PHP : a developer's guide to SEO / Jaimie Sirovich, Cristian Darie. p. cm. Includes index. ISBN 978-0-470-10092-9 (pbk.) 1. PHP (Computer program language) 2. Web sites--Design. 3. Search engines. I. Darie, Cristian. II. Title. QA76.73.P224S525 2007 005.13'3--dc22 2007003317 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permis- sion should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTI CULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTAND- ING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PRO- FESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMA- TION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READ- ERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Microsoft and Excel are registered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page v About the Authors Jaimie Sirovich is a search engine marketing consultant. He works with his clients to build them power- ful online presences. Officially Jaimie is a computer programmer, but he claims to enjoy marketing much more. He graduated from Stevens Institute of Technology with a BS in Computer Science. He worked under Barry Schwartz at RustyBrick, Inc., as lead programmer on e-commerce projects until 2005. At present, Jaimie consults for several organizations and administrates the popular search engine market- ing blog, SEOEgghead.com. Cristian Darie is a software engineer with experience in a wide range of modern technologies, and the author of numerous books and tutorials on AJAX, ASP.NET, PHP, SQL, and related areas. Cristian cur- rently lives in Bucharest, Romania, studying distributed application architectures for his PhD. He’s get- ting involved with various commercial and research projects, and when not planning to buy Google, he enjoys his bit of social life. If you want to say “Hi,” you can reach Cristian through his personal web site at http://www.cristiandarie.ro. 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page vi Credits Acquisitions Editor Vice President and Executive Group Publisher Kit Kemper Richard Swadley Developmental Editor Vice President and Executive Publisher Kenyon Brown Joseph B. Wikert Technical Editor Compositor Bogdan Brinzarea Laurie Stewart, Happenstance Type-O-Rama Production Editor Proofreader Angela Smith Ian Golder Copy Editor Indexer Kim Cofer Melanie Belkin Editorial Manager Anniversary Logo Design Mary Beth Wakefield Richard Pacifico Production Manager Tim Tate 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page vii Acknowledgments The authors would like to thank the following people and companies, listed alphabetically, for their invaluable assistance with the production of this book. Without their help, this book would not have been possible in its current form. Dan Kramer of Volatile Graphix for generously providing his cloaking database to the public — and even adding some data to make our cloaking code examples work better. Kim Krause Berg of The Usability Effect for providing assistance and insight where this book references usability and accessibility topics. MaxMind, Inc., for providing their free GeoLite geo-targeting data — making our geo-targeting code examples possible. Several authors of WordPress plugins including Arne Brachhold, Lester Chan, Peter Harkins, Matt Lloyd, and Thomas McMahon. Family and friends of both Jaimie and Cristian — for tolerating the endless trail of empty cans of (caffeinated) soda left on the table while writing this book. 00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page viii 00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page ix Contents Acknowledgments vii Introduction xvii Chapter 1: You: Programmer and Search Engine Marketer 1 Who Are You? 2 What Do You Need to Learn? 3 SEO and the Site Architecture 4 SEO Cannot Be an Afterthought 5 Communicating Architectural Decisions 5 Architectural Minutiae Can Make or Break You 5 Preparing Your Playground 6 Installing XAMPP 7 Preparing the Working Folder 8 Preparing the Database 11 Summary 12 Chapter 2: A Primer in Basic SEO 13 Introduction to SEO 13 Link Equity 14 Google PageRank 15 A Word on Usability and Accessibility 16 Search Engine Ranking Factors 17 On-Page Factors 17 Visible On-Page Factors 18 Invisible On-Page Factors 20 Time-Based Factors 21 External Factors 22 Potential Search Engine Penalties 26 The Google “Sandbox Effect” 26 The Expired Domain Penalty 26 Duplicate Content Penalty 27 The Google Supplemental Index 27 Resources and Tools 28 Web Analytics 28 00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page x Contents Market Research 29 Researching Keywords 32 Browser Plugins 33 Community Forums 33 Search Engine Blogs and Resources 34 Summary 35 Chapter 3: Provocative SE-Friendly URLs 37 Why Do URLs Matter? 38 Static URLs and Dynamic URLs 38 Static URLs 39 Dynamic URLs 39 URLs and CTR 40 URLs and Duplicate Content 41 URLs of the Real World 42 Example #1: Dynamic URLs 42 Example #2: Numeric Rewritten URLs 43 Example #3: Keyword-Rich Rewritten URLs 44 Maintaining URL Consistency 44 URL Rewriting 46 Installing mod_rewrite 48 Testing mod_rewrite 49 Introducing Regular Expressions 54 URL Rewriting and PHP 60 Rewriting Numeric URLs with Two Parameters 61 Rewriting Keyword-Rich URLs 64 Building a Link Factory 66 Pagination and URL Rewriting 72 Rewriting Images and Streaming Media 72 Problems Rewriting Doesn’t Solve 75 A Last Word of Caution 75 Summary 76 Chapter 4: Content Relocation and HTTP Status Codes 77 HTTP Status Codes 78 Redirection Using 301 and 302 79 301 81 302 82 Removing Deleted Pages Using 404 83 Avoiding Indexing Error Pages Using 500 84 x 00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page xi Contents Redirecting with PHP and mod_rewrite 84 Using Redirects to Change File Names 85 URL Correction 89 Dealing with Multiple Domain Names Properly 90 Using Redirects to Change Domain Names 90 URL Canonicalization: www.example.com versus example.com 91 URL Canonicalization: /index.php versus / 92 Other Types of Redirects 94 Summary 94 Chapter 5: Duplicate Content 95 Causes and Effects of Duplicate Content 96 Duplicate Content as a Result of Site Architecture 96 Duplicate Content as a Result