{"id":7105,"date":"2020-01-31T06:23:22","date_gmt":"2020-01-31T06:23:22","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=7105"},"modified":"2022-02-18T13:23:55","modified_gmt":"2022-02-18T13:23:55","slug":"learn-to-add-or-remove-the-www-prefix-in-domain-urls","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/","title":{"rendered":"Learn to Add or Remove the www Prefix in Domain URLs"},"content":{"rendered":"<p>The article guides you on how to add or remove the www prefix in your domain&#8217;s URLs. For example, if users type www.mydomain.com in their browsers, they automatically get redirected to mydomain.com or vice versa.<\/p>\n<p>While considering Search Engine Optimization (SEO), it is advised that a website should respond only to http:\/\/www.mydomain.com or http:\/\/mydomain.com, but not both. This is because the search engine considers content on www and non-www domains as duplicate and thus may downgrade the site&#8217;s ranking.<\/p>\n<h3># Steps to add www prefix to domain URLs<\/h3>\n<p>Using Apache rewrite rules in custom .htaccess file, allows you to add the www prefix to your domain&#8217;s URL automatically. Perform the following steps to do so :<\/p>\n<p>1) First, create a <strong>.htaccess file<\/strong> in your <strong>public_html directory<\/strong>. In case you already have a .htaccess file in the public_html directory, then you can modify it directly.<\/p>\n<p>2) Copy and paste following commands in the <strong>.htaccess file<\/strong> &#8211;<\/p>\n<div style=\"background-color: #e0ffff; padding: 10px;\"># To add www to any URLs that do not have them use this code:<\/div>\n<div style=\"background-color: #e0ffff; padding: 10px;\">RewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} !^www\\.<br \/>\nRewriteRule ^(.*)$ http:\/\/www.%{HTTP_HOST}\/$1 [R=301,L]<\/div>\n<p>3) Now, save the <strong>.htaccess file<\/strong>.<\/p>\n<p>4) To test the configuration, using a web browser visit<strong> http:\/\/mydomain.com<\/strong>, where mydomain.com represents your domain&#8217;s name. The browser should get redirected to <strong>http:\/\/www.mydomain.com<\/strong><\/p>\n<h3># Steps to remove the www prefix from domain URLs<\/h3>\n<p>Apache rewrite rules in a <strong>custom .htaccess file<\/strong> allows you to automatically remove the www prefix from the domain&#8217;s URLs. Perform the following steps to do it :<\/p>\n<p>1) First, create a <strong>.htaccess file<\/strong> in your <strong>public_html directory<\/strong>. In case you already\u00a0 have a .htaccess file in the public_html directory, you can modify it directly.<\/p>\n<p>2) Copy and paste following commands in the <strong>.htaccess file<\/strong> &#8211;<\/p>\n<div style=\"background-color: #e0ffff; padding: 10px;\">\n<p># To remove www from any URLs that have them:<\/p>\n<p>RewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^www\\.<br \/>\nRewriteRule ^(.*)$ http:\/\/mydomain.com\/$1 [R=301,L]<\/p>\n<\/div>\n<p>3) Make sure you <strong>replace mydomain.com<\/strong> in the final line text with your domain name.<\/p>\n<p>4) Save the <strong>.htaccess file<\/strong>.<\/p>\n<p>5) Now, to test the configuration, using a web browser visit <strong>http:\/\/www.mydomain.com<\/strong>, where mydomain.com represents your domain&#8217;s name. The browser should get redirected to <strong>http:\/\/mydomain.com<\/strong><\/p>\n<p>That&#8217;s it.<\/p>\n<p><strong>Also Read :<\/strong><\/p>\n<p><strong>1)\u00a0<\/strong><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/do-ssl-certificates-work-with-and-without-www-on-domain-at-same-time\/\" target=\"_blank\" rel=\"noopener\"><strong>Do SSL certificates work with and without www on domain at same time ?<\/strong><\/a><\/p>\n<p><strong>2)\u00a0<\/strong><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-configure-caching-with-the-mod_expires-module\/\" target=\"_blank\" rel=\"noopener\"><strong>Learn to configure caching with the mod_expires module<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The article guides you on how to add or remove the www prefix in your domain&#8217;s URLs. For example, if users type www.mydomain.com in their browsers, they automatically get redirected to mydomain.com or vice versa. While considering Search Engine Optimization (SEO), it is advised that a website should respond only to http:\/\/www.mydomain.com or http:\/\/mydomain.com, but [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1242,1243],"class_list":["post-7105","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-domain-name-dns-issues","tag-add-www-prefix-to-url","tag-remove-www-prefix-from-url"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb<\/title>\n<meta name=\"description\" content=\"This guide defines you how to add or remove the www prefix in domain URLs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"og:description\" content=\"This guide defines you how to add or remove the www prefix in domain URLs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-31T06:23:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-18T13:23:55+00:00\" \/>\n<meta name=\"author\" content=\"Sonam Wagh\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sonam Wagh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/\",\"name\":\"Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2020-01-31T06:23:22+00:00\",\"dateModified\":\"2022-02-18T13:23:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\"},\"description\":\"This guide defines you how to add or remove the www prefix in domain URLs.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn to Add or Remove the www Prefix in Domain URLs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\",\"name\":\"Sonam Wagh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cb2cf6ae11d7625ef6417ef8e84ba25?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cb2cf6ae11d7625ef6417ef8e84ba25?s=96&d=blank&r=g\",\"caption\":\"Sonam Wagh\"},\"description\":\"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/sonam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb","description":"This guide defines you how to add or remove the www prefix in domain URLs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/","og_locale":"en_GB","og_type":"article","og_title":"Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb","og_description":"This guide defines you how to add or remove the www prefix in domain URLs.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2020-01-31T06:23:22+00:00","article_modified_time":"2022-02-18T13:23:55+00:00","author":"Sonam Wagh","twitter_misc":{"Written by":"Sonam Wagh","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/","name":"Learn to Add or Remove the www Prefix in Domain URLs - Web Hosting FAQs by MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2020-01-31T06:23:22+00:00","dateModified":"2022-02-18T13:23:55+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4"},"description":"This guide defines you how to add or remove the www prefix in domain URLs.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-add-or-remove-the-www-prefix-in-domain-urls\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Learn to Add or Remove the www Prefix in Domain URLs"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4","name":"Sonam Wagh","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cb2cf6ae11d7625ef6417ef8e84ba25?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cb2cf6ae11d7625ef6417ef8e84ba25?s=96&d=blank&r=g","caption":"Sonam Wagh"},"description":"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/sonam\/"}]}},"views":578,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/7105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=7105"}],"version-history":[{"count":2,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/7105\/revisions"}],"predecessor-version":[{"id":13761,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/7105\/revisions\/13761"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=7105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=7105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=7105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}