Forum Moderators: phranque

Message Too Old, No Replies

.htacces duplicate content .php - .html (multi domain)

.htacces duplicate content .php - .html (multi domain)

         

ebikekit

12:13 am on Jul 5, 2010 (gmt 0)

10+ Year Member



Hi everyone,

I’m having an canonical .htaccess issue and the longer i’m trying to manage it, the more stuck I get.

Situation:
To make sure customers find us, we’ve claimed of our company name with all possible hyphens (-), such as: ebikekit.nl, ebike-kit.nl, e-bikekit.nl. Our html pages are written in php and rewritten to html to prevent duplicate content.

Problem:
The default 301 redirects work, but i’m having problems with duplicate content between page.html and page.php.

.htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]*)\.html$ $1.php?%{QUERY_STRING} [NC]
RewriteCond %{HTTP_HOST} ^ebike-kit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^ebikekit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^e-bikekit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^e-bike-kit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.ebikekit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.e-bikekit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.e-bike-kit.nl [NC]
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
ErrorDocument 404 /page-not-found.html
Redirect 301 /veelgestelde_vragen.html http://www.ebike-kit.nl/veelgestelde-vragen.html
Redirect 301 /hoe_het_werkt.html http://www.ebike-kit.nl/hoe-het-werkt.html
Redirect 301 /hoe-het-werkt http://www.ebike-kit.nl/hoe-het-werkt.html
</IfModule>


Who can help me?
Thanks!

jdMorgan

2:08 am on Jul 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Re-arrange, re-code, and add one more rule:

.htaccess file:

ErrorDocument 404 /page-not-found.html
#
RewriteEngine On
RewriteBase /
#
# Externally redirect only direct client requests for .php URLs to .html URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*([^.]+\.)+php(?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*([^.]+\.)+)php http://www.ebike-kit.nl/$1.html [R=301,L]
#
# Externally redirect specific incorrect URLs to correct URLs
RewriteRule ^veelgestelde_vragen\.html$ http://www.ebike-kit.nl/veelgestelde-vragen.html [R=301,L]
RewriteRule ^hoe-het-werkt http://www.ebike-kit.nl/hoe-het-werkt.html [R=301,L]
#
# Externally redirect all non-blank non-canonical hostname requests
RewriteCond %{HTTP_HOST} !^(www\.ebike-kit\.nl)?$
RewriteRule (.*) http://www.ebike-kit.nl/$1 [R=301,L]
#
# Internally rewrite .html URL requests to .php files
RewriteRule ^(.+)\.html$ /$1.php [NC,L]

Do not mix "Redirect" and "RewriteRule" directives. Otherwise, you cannot control execution order.
Note the "redirect URL to URL" and "Rewrite URL to filepath" distinction.
Note that both redirect and rewrite group rules are ordered from most-specific to least-specific.
Note that all redirects are done before any rewrites are done.
<IfModule> is not needed unless you want the code to fail silently if mod_rewrite is not available.

Jim