Advertise
Content-rich web directory
Zyas Premium Web Directory
Drop Me an Entrecard
Top Entrecard Droppers
Top Level Web Directory Categories
  • I enjoyed the 60 minutes with Barak and Biden, check it out http://tinyurl.com/62sz53
  • I would love to see a pole on digg for presidential candidates. I always see it flooed with praises of Obama and bashing of McCain.
  • You can force OIOPublisher banners to open in a new window with just a few minor edits. http://tinyurl.com/6s2guc
  • Posted the Entrecards, The Dropper How To (http://tinyurl.com/6hmg5o) another great How To from Lobo Links
  • Congrats to Entrecard for their latest creation Entrebar http://tinyurl.com/5pygbw. Now if they could only cure that bounce rate problem.

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

November 28th, 2007 by Mack

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.  (ie www.lobolinks.com OR lobolinks.com).

(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
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:
  1. # BEGIN WordPress
  2. <IfModule mod_rewrite.c>
  3. RewriteEngine On
  4.    #----Redirect index.php---------------------
  5. RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog/index\.php\ HTTP/
  6. RewriteRule ^index\.php$ http://www.lobolinks.com/blog/ [R=301,L]
  7.      #----Forcing the www------------------------
  8. RewriteBase /blog/
  9. RewriteCond %{HTTP_HOST} ^lobolinks.com$
  10. RewriteRule ^(.*)$ http://www.lobolinks.com/blog/$1 [R=301,L]
  11. RewriteCond %{REQUEST_FILENAME} !-f
  12. RewriteCond %{REQUEST_FILENAME} !-d
  13. RewriteRule . /blog/index.php [L]
  14. </IfModule>
  15. # END WordPress

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • StumbleUpon
  • Sphinn
  • Mixx
  • Reddit
  • Technorati

Related Post

2 Responses

  1. By Andy Beard on Nov 29, 2007 | Reply

    I haven't decided what I am going to do with .htaccess changes in WP2.3.1 which has a number of rewrite rules built in and I want to avoid conflicts.
    Watch out for the script kiddies if you are running 2.2.2

  2. By Mack on Nov 30, 2007 | Reply

    Andy, just a little update on this. I upgraded to 3.1 and everything works fine. The only problem I have found is if you allow wordpress to write to your .htaccess.

    It overwrites the code and the hack no longer works.

Leave a Reply