[{"data":1,"prerenderedAt":179},["ShallowReactive",2],{"\u002Farticles\u002Fdealing-with-www":3},{"id":4,"title":5,"body":6,"createdAt":170,"description":12,"extension":171,"meta":172,"navigation":173,"path":174,"rawbody":175,"seo":176,"stem":177,"__hash__":178},"articles\u002Farticles\u002Fdealing-with-www.md","Dealing with WWW",{"type":7,"value":8,"toc":168},"minimark",[9,13,21,32,54,57,116,119,161,164],[10,11,12],"p",{},"When you're finishing up a new site or revisiting an old one, it's a smart choice to make sure your URL is loaded the same way, with or without the www record.",[10,14,15,16,20],{},"In some cases, ",[17,18,19],"code",{},"www.domain.com"," serves different content than domain.com. However, for a vast majority of sites users get the same content either way, so it's important to setup your site so that there is a consistent URL that visitors' and search engine crawlers see. It's an easy fix…",[10,22,23,24,31],{},"You need to have an ",[25,26,30],"a",{"href":27,"rel":28},"http:\u002F\u002Fwww.javascriptkit.com\u002Fhowto\u002Fhtaccess.shtml",[29],"nofollow",".htaccess"," file, and have the mod_rewrite engine turned on:",[33,34,39],"pre",{"className":35,"code":36,"filename":30,"language":37,"meta":38,"style":38},"language-bash shiki shiki-themes github-light github-dark","RewriteEngine On\n","bash","",[17,40,41],{"__ignoreMap":38},[42,43,46,50],"span",{"class":44,"line":45},"line",1,[42,47,49],{"class":48},"sScJk","RewriteEngine",[42,51,53],{"class":52},"sZZnC"," On\n",[10,55,56],{},"Then, it's just two lines to make your site either add www:",[33,58,60],{"className":35,"code":59,"filename":30,"language":37,"meta":38,"style":38},"# Add WWW\nRewriteCond %{HTTP_HOST} ^domain.com$ [NC]\nRewriteRule ^(.*)$ http:\u002F\u002Fwww.domain.com\u002F$1 [R=301,L]\n",[17,61,62,68,84],{"__ignoreMap":38},[42,63,64],{"class":44,"line":45},[42,65,67],{"class":66},"sJ8bj","# Add WWW\n",[42,69,71,74,77,80],{"class":44,"line":70},2,[42,72,73],{"class":48},"RewriteCond",[42,75,76],{"class":52}," %{HTTP_HOST}",[42,78,79],{"class":52}," ^domain.com",[42,81,83],{"class":82},"sVt8B","$ [NC]\n",[42,85,87,90,93,96,100,103,106,109,113],{"class":44,"line":86},3,[42,88,89],{"class":48},"RewriteRule",[42,91,92],{"class":52}," ^",[42,94,95],{"class":82},"(",[42,97,99],{"class":98},"sj4cs",".",[42,101,102],{"class":52},"*",[42,104,105],{"class":82},")$ ",[42,107,108],{"class":52},"http:\u002F\u002Fwww.domain.com\u002F",[42,110,112],{"class":111},"s4XuR","$1",[42,114,115],{"class":82}," [R=301,L]\n",[10,117,118],{},"Or, to drop it like I've done on my own site:",[33,120,122],{"className":35,"code":121,"filename":30,"language":37,"meta":38,"style":38},"# Remove WWW\nRewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]\nRewriteRule ^(.*)$ http:\u002F\u002Fdomain.com\u002F$1 [R=301,L]\n",[17,123,124,129,140],{"__ignoreMap":38},[42,125,126],{"class":44,"line":45},[42,127,128],{"class":66},"# Remove WWW\n",[42,130,131,133,135,138],{"class":44,"line":70},[42,132,73],{"class":48},[42,134,76],{"class":52},[42,136,137],{"class":52}," ^www.domain.com",[42,139,83],{"class":82},[42,141,142,144,146,148,150,152,154,157,159],{"class":44,"line":86},[42,143,89],{"class":48},[42,145,92],{"class":52},[42,147,95],{"class":82},[42,149,99],{"class":98},[42,151,102],{"class":52},[42,153,105],{"class":82},[42,155,156],{"class":52},"http:\u002F\u002Fdomain.com\u002F",[42,158,112],{"class":111},[42,160,115],{"class":82},[10,162,163],{},"That's it! Depending on which version you choose, visitors and crawlers will be automatically redirected to the correct setting of your domain.",[165,166,167],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":38,"searchDepth":70,"depth":70,"links":169},[],"2011\u002F01\u002F07","md",{},true,"\u002Farticles\u002Fdealing-with-www","---\ntitle: Dealing with WWW\ncreatedAt: 2011\u002F01\u002F07\n---\nWhen you're finishing up a new site or revisiting an old one, it's a smart choice to make sure your URL is loaded the same way, with or without the www record.\n\nIn some cases, `www.domain.com` serves different content than domain.com. However, for a vast majority of sites users get the same content either way, so it's important to setup your site so that there is a consistent URL that visitors' and search engine crawlers see. It's an easy fix…\n\nYou need to have an [.htaccess](http:\u002F\u002Fwww.javascriptkit.com\u002Fhowto\u002Fhtaccess.shtml) file, and have the mod_rewrite engine turned on:\n\n```bash[.htaccess]\nRewriteEngine On\n```\n\nThen, it's just two lines to make your site either add www:\n\n```bash[.htaccess]\n# Add WWW\nRewriteCond %{HTTP_HOST} ^domain.com$ [NC]\nRewriteRule ^(.*)$ http:\u002F\u002Fwww.domain.com\u002F$1 [R=301,L]\n```\n\nOr, to drop it like I've done on my own site:\n\n```bash[.htaccess]\n# Remove WWW\nRewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]\nRewriteRule ^(.*)$ http:\u002F\u002Fdomain.com\u002F$1 [R=301,L]\n```\n\nThat's it! Depending on which version you choose, visitors and crawlers will be automatically redirected to the correct setting of your domain.\n",{"title":5,"description":12},"articles\u002Fdealing-with-www","58Z4zb1aQKSsyUM0x5Vgd-CJ4MmH-fNmjGPyihvt8zw",1794877726967]