My .htaccess file contains code at the top for my wordpress permalinks, so I add the redirects below that.Here’s the Wordpress code along with canonicalization.
# .htaccess
#
# ————————————————————————————
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# - BEGIN - CANONICALIZATION
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
# - END -
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# ————————————————————————————–
# Edit Your Affiliate Redirects Below Hereredirect 301 /get/this-great-affiliate-product http://www.wpAffiliateGuide.com/?affid=affiliate-ID
Note that the lines with # symbol in front are comments
Canonicalization
This just makes your URL path always have the www. in front. Google assigns PageRank to http://www.mysite.com/ and http://mysite.com/ as two separate pages. So if some people link to your site with the www. and some without, your PageRank gets split up and you don’t get as much credit for one or the other as you should. In some cases, these are actually two different pages, so Google has to keep the algorithm this way.
File Naming
When using an editor in Windows XP, you cannot save the file with only a . (dot) extension such as the .htaccess file. You’ll get the error message that says, “You must enter a file name.” Thank you Microsoft!
I save the file as x.htaccess, and then use my FileZilla FTP manager to rename it.
301 Permanent Redirects
The bottom of the example above shows a line of code to use in your .htaccess file that will redirect anyone who clicks on it (all on one line, even if it does not appear so here). Google and other search engines, will consider it a permanent redirect and give link reputation to the final target, whether you link to your own pages or someone elses. –
redirect 301 /get/wpaffiliateguide http://www.wpAffiliateGuide.com/?affid=affiliate-ID
To use this link, you would simply enter it like this –
http://www.JerryLeventer.com/get/wpaffiliateguide
In this example you will be redirected to Teli Adlam’s latest product page. If you make the purchase, my account will be given credit for the sale. This link will open in a new window (or tab).
[tags]URL Canonicalization, Cloaked Affiliate Links, dot htaccess files, 301 Permanent Redirects, Wordpress Permalinks[/tags]
2 responses so far ↓
1 Jeff Starr // Mar 15, 2008 at 5:14 pm
Hi, this is my second attempt at leaving a comment on this post, so I hope it makes it through! Anyway, just wanted to share my comprehensive WordPress canonicalization technique with your readers. It should certainly help your readers with their URL canonicalization efforts. Cheers!
2 Jerry Leventer // Mar 15, 2008 at 9:11 pm
Hi Jeff,
Not sure what happened, but it came through this time. Your site, Perishible Press, has valuable content for developers. Thanks for the head’s up.
Leave a Comment