Homepage

Forcing the WordPress index.php to the Main Url and Avoiding Duplicate Content with a .htaccess

November 28th, 2007

Duplicate Content on a large scale basis can ruin your blog.  I blame it on the search engines for not being smart enough to know exactly what you want, but in any case you can easily avoid this problem with your WordPress .htaccess.  In reality what you are doing is forcing a www. or non-www. prefix for your domain. 

(seen end of post for code)

Forcing that WordPress index.php to the main URL easy

Most search engines obviously can not determine your targeted prefix or that index.php is the same as main url.  The good news is that by making some small changes in your .htaccess you can correct this problem and search engines will follow suite.

Check out these examples by copying and pasting the following links into your browser:
http://www.lobolinks.com/index.php
http://www.lobolinks.com/blog/index.php

Here is the code for both Hacks

Be sure to change the urls to match your site.  If you have any problems let me know or catch me on MSN. This was tested on 2.2.2 and 2.3.1

[html]
# BEGIN WordPress

RewriteEngine On
#—-Redirect index.php———————
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog/index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.lobolinks.com/blog/ [R=301,L]
#—-Forcing the www————————
RewriteBase /blog/
RewriteCond %{HTTP_HOST} ^lobolinks.com$
RewriteRule ^(.*)$ http://www.lobolinks.com/blog/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress
[/html]

Posted in Blogging, Internal SEO • Tags: ,