This is usually what you want regardless.
Our final note on the .htaccess rules regards the following code:
# Redirect to correct domain to avoid canonicalization problems
#RewriteCond %{HTTP_HOST} !^www\.example\.com
#RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
As you can see, the RewriteCond and RewriteRule commands are commented out using
the # character. We commented these lines, because you should change www.example.com to
the location of your web site before uncommenting them (while working on localhost, leave
these rules commented out).
RewriteCond is a mod_rewrite command that places a condition for the rule that follows. In
this case, you??™re interested in verifying that the site has been accessed through www.example.com.
If it hasn??™t, you do a 301 redirect to www.example.com. This technique implements domain name
canonicalization. If your site can be accessed through multiple domain names (such as
www.example.com and example.com), establish one of them as the main domain and redirect all
the others to it, avoiding duplicate content penalties from the search engines. You??™ll learn more
about 301 redirects a bit later in this chapter.
CHAPTER 7 ?– SEARCH ENGINE OPTIMIZATION 198
Building Keyword-Rich URLs
In the previous exercise, you achieved a great thing: you??™ve started supporting keyword-rich
URLs in TShirtShop! However, note that
??? Your site supports dynamic URLs as well.
Pages:
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309