Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Forcing example.com and not www.example.com

getting ride of duplicate content

         

niki_man

4:18 am on Jul 13, 2005 (gmt 0)

10+ Year Member



In a effort to get rid of duplicate content...

How do I the search engins to go permanently from: http://www.example.com/content-1232.html
to
http://example.com/content-1232.html

This is my .htaccess


RewriteEngine on
RewriteRule ^content(.*)\.html$ /index.php?id=$1";

$htaccessban = "
<Limit GET>
order deny,allow
deny from d.example.com
deny from f.example.com
deny from g.example.com
</Limit>

ErrorDocument 404 /

I tried all the modrewrite codes mentioned in
[webmasterworld.com...] . But nothing worked.

[edited by: ciml at 11:33 am (utc) on July 13, 2005]
[edit reason] Examplified [/edit]

Clint

11:52 am on Jul 13, 2005 (gmt 0)



I don't know if you tried this or not, but it worked for me on one of my domains where the non-www had a higher PR than the www version. So, this directs www to non-www:

RewriteEngine on
RewriteCond %{HTTP_HOST}!^MyDomain\.com
RewriteRule (.*) [MyDomain.com...] [R=301,L]

This is on Linux/Apache and cPanel's htaccess file.

niki_man

2:36 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



I'll give that a try... then report back...

Swebbie

3:44 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



Does anyone know if using the following two sections of the 301 code are identical?

[R=301,L]

[R=permanent,L]

Are they interchangeable? Thanks!

jtbell

6:26 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



Yes, they're interchangeable, according to the Apache manual. You can also use appropriate words instead of the letters for the flags:

[redirect=permanent,last]

jd01

11:29 pm on Jul 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might find better answers in the Apache Forum [webmasterworld.com].

I would guess someone there would notice the correct rewrite for this:

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

Is actually this:
RewriteEngine on
RewriteCond ${HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^MyDomain\.com
RewriteRule (.*) http://MyDomain.com/$1 [R=301,L]

If the top line, which checks for any single character in the HOST header to indicate that the browser is capable of sending the appropriate header, is not added HTTP 1.0 clients (or others) that do not send HOST headers will get caught in an infinite loop, becuase their HOST will always be !(not) MyDomain.com, as it is empty.

Justin