apache - How to avoid duplicate content mapping urls with htaccess -
apache - How to avoid duplicate content mapping urls with htaccess -
i'm kind of new writing htaccess rules. want create urls in website simple possible.
let's want "map" /home/ directory root domain. so, http://www.domain.com display content /home/ directory without changing url.
moreover, don't want users / google access to: http://www.domain.com/home/, so, if goes url, want redirect them root domain: http://www.domain.com.
i'm seeing google indexing both directories same duplicate content. http://www.domain.com http://www.domain.com/home/
is there can stop this? don't want utilize robots.txt because i've heard it's bad practice.
rewriteengine on rewritebase / # redirect /home/ dir 'www.domain.com' #rewritecond %{request_uri} ^/home/$ [nc] #rewriterule ^(.*)$ / [r=301,l] # show /home/ dir 'www.domain.com' rewritecond %{http_host} ^www\.domain\.com [nc] rewritecond %{request_uri} ^/$ rewriterule ^(.*)$ /home/$1 [l]
if enable lines code, redirect loop never ends.
also, i'm facing same problem when trying add together "seo friendly" urls. i'm trying map "http://www.domain.com/thread/thread-name/" "http://forum.domain.com/thread-name/", , although works fine, i'm still having 2 duplicate urls showing same content.
i heard best practice avoid search engines indexing duplicate content. should redirect 404? don't want utilize robots.txt implement because there're lots of files / directories combination, , won't work purpose.
thanks lot!
instead of this:
# redirect /home/ dir 'www.domain.com' #rewritecond %{request_uri} ^/home/$ [nc] #rewriterule ^(.*)$ / [r=301,l]
try:
# redirect /home/ dir 'www.domain.com' rewritecond %{the_request} \ /+home/([^\?\ ]*) rewriterule ^ /%1 [r=301,l]
apache .htaccess redirect seo duplicate-content
Comments
Post a Comment