homepage Welcome to WebmasterWorld Guest from 107.22.45.61
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
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
brnm98105




msg:3921817
 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]

 

jdMorgan




msg:3921833
 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.

Jim

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved