Force to www. with .htaccess

Discussion in 'Apache' started by crazyryan, Jan 19, 2008.

  1. #1
    Hey,

    How can I make site.com go to www.site.com as well as any other page like site.com/32423/ to www.site.com/32423/

    Thanks

    EDIT:
    I found this:
    RewriteCond %{HTTP_HOST} ^arcadedark\.com [NC]
    RewriteRule ^(.*)$ http://www.arcadedark.com/$1 [R=301,L]

    Which is working, kind of..

    I'm also using

    RewriteRule "^game/([0-9]+)/$" file.php?id=$1 [Last]
    RewriteRule "^category/([0-9]+)/([0-9]+)/$" category.php?id=$1&page=$2 [Last]

    Which stops functioning when I use arcadedark.com/game/4234/
     
    crazyryan, Jan 19, 2008 IP
  2. baumann93

    baumann93 Peon

    Messages:
    2,268
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What do you mean by "kind of" working? That code adds www to your domain. What else do you want it to do?

    The last two rewrite rules look OK but you need to remove double quotations around strings and use [L] instead of [Last].
     
    baumann93, Jan 21, 2008 IP
  3. googleminigames.com

    googleminigames.com Banned

    Messages:
    1,335
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i did something like this to my site :) all www. requests go to http://
     
    googleminigames.com, Jan 21, 2008 IP
  4. Krnl

    Krnl Peon

    Messages:
    60
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    I prefer mine to point to my url without the www as well. It's a matter of personal preference. As long as the whole site is one way or the other, then it's a good move from an SEO perspective.
     
    Krnl, Jan 22, 2008 IP
  5. baumann93

    baumann93 Peon

    Messages:
    2,268
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You might get a duplicate content penalty if you do not rewrite non www to www or vice versa. SEs might see pages without www being duplicates of pages with www.
     
    baumann93, Jan 22, 2008 IP