Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

redirect to prevent duplicate content



4:42 pm on May 28, 2009 (gmt 0)

5+ Year Member

Hi I have a question of anyone who can help.

I have a Blog built within my site

When I find my blog in the search engine it points to example.com/blog with no WWW. My main site www.example.com looks fine and my htaccess redirects fine.

How do I make it work for my blog also?

This is what I have

ErrorDocument 404 /404page.htm
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

Any help would be appreciated.

[edited by: jdMorgan at 5:10 pm (utc) on May 28, 2009]
[edit reason] example.com [/edit]


5:13 pm on May 28, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

In the mod_rewrite code in the .htaccess file in your /blog subdirectory, try adding

RewriteOptions inherit

This is set by default on most hosting companies' servers, but not always.

The other alternative is to duplicate the redirection code in /blog/.htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/blog/$1 [R=301,L]

(Note the corrections: These apply to your main code as well, except for the addition of the /blog path-part.)

Make sure that all links within your own site point to www.example.com, and not to example.com. You don't want to confuse the search engines, and you don't want to make your visitors suffer a redirect delay unnecessarily.



Featured Threads

Hot Threads This Week

Hot Threads This Month