Wrox professional search engine optimization with PHP apr 2007 - Pdf 99


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 iii
00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page ii
Professional
Search Engine
Optimization with PHP
00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page i
00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page ii
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 iii
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

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 iv
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 v
Credits

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 vii
00929ffirs.qxd:00929ffirs 3/13/07 10:36 AM Page viii
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

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
00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page x
xi
Contents

JavaScript Links 121
DHTML Menus 121
Popup Windows 121
DHTML Popup Windows 129
Crawlable Images and Graphical Text 129
Search Engine–Friendly HTML 140
HTML Structural Elements 141
Copy Prominence and Tables 141
00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page xi
xii
Contents
Frames 144
Using Forms 144
Using a Custom Markup Language to Generate SE-Friendly HTML 145
Flash and AJAX 149
The Blended Approach 149
Summary 150
Chapter 7: Web Feeds and Social Bookmarking 151
Web Feeds 151
RSS and Atom 152
Creating RSS Feeds 154
Syndicating RSS and Atom Feeds 160
Other Sources of Syndicated Content 164
Social Bookmarking 164
Summary 172
Chapter 8: Black Hat SEO 173
What’s with All the Hats? 174
Bending the Rules 175
Technical Analysis of Black-Hat Techniques 176
Attack Avoidance 177

Summary 218
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery 219
Cloaking, Geo-Targeting, and IP Delivery 219
More on Geo-Targeting 220
A Few Words on JavaScript Redirect Cloaking 221
The Ethical Debate on Cloaking 221
Cloaking Dangers 222
Using the Meta Noarchive Tag 222
Implementing Cloaking 223
Cloaking Case Studies 232
Rendering Images as Text 233
Redirecting Excluded Content 233
Feeding Subscription-Based Content Only to Spiders 233
Disabling URL-Based Session Handling for Spiders 234
Other Cloaking Implementations 234
Implementing Geo-Targeting 234
Summary 241
Chapter 12: Foreign Language SEO 243
Foreign Language Optimization Tips 243
Indicating Language and Region 244
Server Location and Domain Name 244
Include the Address of the Foreign Location if Possible 245
Dealing with Accented Letters (Diacritics) 245
Foreign Language Spamming 248
Summary 248
00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page xiii
xiv
Contents
Chapter 13: Coping with Technical Issues 249
Unreliable Web Hosting or DNS 249

Sociable: Social Bookmarking Icons 295
WP-Email: Email a Friend 296
Chicklet Creator Plugin 298
00929ftoc.qxd:00929ftoc 3/13/07 2:02 PM Page xiv
xv
Contents
Sitemap Generator Plugin 299
Google Sitemaps Plugin 301
Digg Button Plugin 304
Pagerfix Plugin 305
Eliminating Duplicate Content 307
Pull-downs and Excluding Category Links 308
Excerpting Article Content 309
Making the Blog Your Home Page 309
Summary 310
Appendix A: Simple Regular Expressions 311
Matching Single Characters 312
Matching Sequences of Characters That Each Occur Once 317
Introducing Metacharacters 319
Matching Sequences of Different Characters 324
Matching Optional Characters 326
Matching Multiple Optional Characters 328
Other Cardinality Operators 332
The * Quantifier 332
The + Quantifier 334
The Curly-Brace Syntax 336
The {n} Syntax 336
The {n,m} Syntax 337
{0,m} 337
{n,m} 339

ing implementations of cloaking and geo-targeting.
What Will You Learn from this Book?
In this book, we have assembled the most important topics that programmers and search engine marketers
should know about when designing web sites.
00929flast.qxd:00929flast 3/13/07 10:37 AM Page xvii
At the end of Chapter 1, You: Programmer and Search Engine Marketer, you create the environment
where you’ll be coding away throughout the rest of the book. Programming with PHP can be tricky at
times; in order to avoid most configuration and coding errors you may encounter, we will instruct you
how to prepare the working folder and your MySQL database.
If you aren’t ready for these tasks yet, don’t worry! You can come back at any time, later. All
programming-related tasks in this book are explained step by step to minimize the chances that
anyone gets lost on the way.
Chapter 2, A Primer in Basic SEO, is a primer in search engine optimization tailored for the IT profes-
sional. It stresses the points that are particularly relevant to the programmer from the perspective of the
programmer. You’ll also learn about a few tools and resources that all search engine marketers and web
developers should know about.
Chapter 3, Provocative SE-Friendly URLs, details how to create (or enhance) your web site with improved
URLs that are easier for search engines to understand and more persuasive for their human readers. You’ll
even create a URL factory, which you will be able to reuse in your own projects.
Chapter 4, Content Relocation and HTTP Status Codes, presents all of the nuances involved in using
HTTP status codes correctly to relocate and indicate other statuses for content. The proper use of these
status codes is essential when restructuring information on a web site.
Chapter 5, Duplicate Content, discusses duplicate content in great detail. It then proposes strategies for
avoiding problems related to duplicate content.
Chapter 6, SE-Friendly HTML and JavaScript, discusses search engine optimization issues that present
themselves in the context of rendering content using HTML, JavaScript and AJAX, and Flash.
Chapter 7, Web Feeds and Social Bookmarking, discusses web syndication and social bookmarking.
Tools to create feeds and ways to leverage social bookmarking are presented.
Chapter 8, Black Hat SEO, presents black hat SEO from the perspective of preventing black hat victim-
ization and attacks. You may want to skip ahead to this chapter to see what this is all about!

site and suggests enhancements that can be implemented in the context of their difficulty.
Lastly, Chapter 16, WordPress: Creating an SE-Friendly Blog, documents how to set up a search
engine–optimized blog using WordPress 2.0 and quite a few custom plugins.
We hope that you will enjoy reading this book and that it will prove useful for your real-world search
engine optimization endeavors!
Contacting the Authors
Jaimie Sirovich can be contacted through his blog at http://www.seoegghead.com. Cristian Darie can
be contacted from his web site at
http://www.cristiandarie.ro.
Conventions
To help you get the most from the text and keep track of what’s happening, we’ve used a number of
conventions throughout the book.
Tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
Boxes like this one hold important, not-to-be forgotten information that is directly
relevant to the surrounding text.
Introduction
xix
00929flast.qxd:00929flast 3/13/07 10:37 AM Page xix
As for styles in the text:
❑ We highlight new terms and important words when we introduce them.
❑ We show keyboard strokes like this: Ctrl+A.
❑ We show file names, URLs, and code within the text like so:
persistence.properties.
❑ We present code in two different ways:
In code examples we highlight new and important code with a gray background.
The gray highlighting is not used for code that’s less important in the present
context, or has been shown before.
Source Code
As you work through the examples in this book, you may choose either to type in all the code manually
or to use the source code files that accompany the book. All of the source code used in this book is

of the book.
Introduction
xx
00929flast.qxd:00929flast 3/13/07 10:37 AM Page xx
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a web-based system
for you to post messages relating to Wrox books and related technologies and interact with other readers
and technology users. The forums offer a subscription feature to email you topics of interest of your choos-
ing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow
readers are present on these forums.
At
http://p2p.wrox.com you will find a number of different forums that will help you not only as you
read this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you wish to pro-
vide and click Submit.
4. You will receive an email with information describing how to verify your account and complete
the joining process.
You can read messages in the forums without joining P2P but in order to post your own messages, you
must join.
Once you join, you can post new messages and respond to messages other users post. You can read mes-
sages at any time on the web. If you would like to have new messages from a particular forum emailed
to you, click the Subscribe To This Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to ques-
tions about how the forum software works as well as many common questions specific to P2P and Wrox
books. To read the FAQs, click the FAQ link on any P2P page.
Introduction
xxi
00929flast.qxd:00929flast 3/13/07 10:37 AM Page xxi


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status