Need some help with .htaccess to avoid duplicate content

Discussion in 'Search Engine Optimization' started by AllOutAnime, Jun 29, 2008.

  1. #1
    Hello, this is an url rewrite for my wiki page (site.com/wiki/article)

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
    RewriteRule ^wiki/*$ wiki/ [L,QSA]
    RewriteRule ^/*$ wiki/ [L,QSA]
    Code (markup):
    Now here I got an url rewrite to avoid duplicate content:

    RewriteCond %{HTTP_HOST} !^www\.site\.com$
    RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
    Code (markup):

    Can you somehow combine them in 1 .htaccess file? If I just put them together it doesen´t work.

    Thanks for your help.
     
    AllOutAnime, Jun 29, 2008 IP
  2. AllOutAnime

    AllOutAnime Peon

    Messages:
    186
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ok since nobody is doing that for free, I´m offering the service here (5500 posts, backlinks worth $10) for the person who gives me a working code from the above one time for free.

    Greetings
    AllOutAnime
     
    AllOutAnime, Jul 2, 2008 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
    RewriteRule ^wiki/*$ wiki/ [L,QSA]
    RewriteRule ^/*$ wiki/ [L,QSA]
    </IfModule>
     
    misohoni, Jul 3, 2008 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm not a mod_rewrite expert, but I highly doubt the <ifModule mod_rewrite.c> statement is even necessary. Feel free to correct me if I'm wrong, but bear in mind I know not one but two mod_rewrite experts and I will be consulting with both of them just to make sure.
     
    Dan Schulz, Jul 3, 2008 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    but i thought it was the best way to merge the statements...I use it on my Wordpress .htaccess and it works...
     
    misohoni, Jul 3, 2008 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If my memory serves me correctly, it basically checks to see if mod_rewrite is active or not.
     
    Dan Schulz, Jul 3, 2008 IP
  7. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #7
    yep I think you're right, but i used the above code on my site and it worked..although alloutanime guy didn't say if it worked for him!
     
    misohoni, Jul 3, 2008 IP
  8. AllOutAnime

    AllOutAnime Peon

    Messages:
    186
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It worked even without the <IfModule mod_rewrite.c>, thanks.

    Greetings
    AllOutAnime
     
    AllOutAnime, Jul 6, 2008 IP
  9. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #9
    So, AllOutAnime...I give you my info now for the free "5500 posts, backlinks worth $10" ;)
     
    misohoni, Jul 6, 2008 IP
  10. AllOutAnime

    AllOutAnime Peon

    Messages:
    186
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    please pm it
     
    AllOutAnime, Jul 7, 2008 IP