homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

redirect to prevent duplicate content

5+ Year Member

Msg#: 3921815 posted 4:42 pm on May 28, 2009 (gmt 0)

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]



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

Msg#: 3921815 posted 5:13 pm on May 28, 2009 (gmt 0)

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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved