{"id":941,"date":"2015-10-26T18:15:13","date_gmt":"2015-10-26T18:15:13","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=941"},"modified":"2023-03-14T14:13:39","modified_gmt":"2023-03-14T14:13:39","slug":"redirect-non-www-to-www-http-to-https-using-htaccess-file","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/","title":{"rendered":"Redirect non-www to www &#038; HTTP to HTTPS using .htaccess file"},"content":{"rendered":"<p><code>.htaccess<\/code> file is a configuration file used to override the main server configuration. <code>.htaccess<\/code> file placed in a directory and the configuration is applied to that particular directory and all the subdirectories. The most usage of <code>.htaccess<\/code> file is Rewriting URLs, Blocking, SSL, Customized error responses, Directory listing, Cache-Control, etc.<\/p>\n<p>You can define the conditional URL rewrite rules using <b>RewriteCond<\/b> and <b>RewriteRule<\/b> in HTACCESS. This HTACCESS tutorial will show you the most used URL redirection process through the .htaccess file. At first, you&#8217;ll see how to redirect non-www URLs to www and the second one will show you how to redirect HTTP to HTTPS using a .htaccess file.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\" alt=\"redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld\" width=\"624\" height=\"366\" class=\"alignnone size-full wp-image-942\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png 624w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-300x176.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-350x205.png 350w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-320x188.png 320w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-380x223.png 380w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-200x117.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld-346x203.png 346w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/div>\n<h2>Create .htaccess File<\/h2>\n<p>Create a file with <code>.htaccess<\/code> extension in the root directory of the website domain. It will be a simple text file and you can edit this file with any text editor.<\/p>\n<h2>Redirect non-www to www URL<\/h2>\n<p>As per the Search Engine prospect, non-www and www URLs are different and it could affect website SEO. For example, <code>http:\/\/codexworld.com<\/code> and <code>http:\/\/www.codexworld.com<\/code> are technically different in Search Engines. When a Search Engine fetches the same content from different URLs, it is treated as duplicate content. So, it will be a good idea if you redirect all requests (non-www) to the same URL format (www). Using the .htaccess file, you can easily redirect non-www to www URL.<\/p>\n<p>Add the following code in the root <code>.htaccess<\/code> file to redirect the non-www to www URL.<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteEngine<\/span><\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">On<\/span>\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteCond<\/span><\/span> <span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span> !^www\\.\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteRule<\/span><\/span> ^(.*)$ http:\/\/www.<span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span>\/<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">$1<\/span><span class=\"hljs-meta\" style=\"color: rgb(31, 113, 153);\"> [R=301,L]<\/span><\/pre>\n<h2>Redirect HTTP to HTTPS URL<\/h2>\n<p>If the secure certificate (SSL) was installed on your website, you can redirect visitors to the secure web version. Sometimes SSL encrypted connection is necessary for your website. This means you would like to force website visitors to use SSL by automatically redirecting HTTP to HTTPS version of the URL. <\/p>\n<p>Add the following code in the root .htaccess file to redirect the HTTP to HTTPS URL.<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteEngine<\/span><\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">On<\/span>\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteCond<\/span><\/span> <span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTPS}<\/span> !=<span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">on<\/span>\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteRule<\/span><\/span> ^(.*)$ https:\/\/<span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span>\/<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">$1<\/span><span class=\"hljs-meta\" style=\"color: rgb(31, 113, 153);\"> [L,R=301]<\/span><\/pre>\n<h2>Redirect HTTP &#038; non-www to HTTPS &#038; www URLs<\/h2>\n<p>It&#8217;s always been a good idea to maintain the same URL format for all the requests. To fulfill this purpose, redirect non-www and HTTP requests to HTTPS and www formatted URLs.<\/p>\n<p>The following HTACCESS code snippet redirects all HTTP &#038; non-www requests to HTTPS &#038; www URL.<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteEngine<\/span><\/span> <span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">On<\/span> \r\n\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteCond<\/span><\/span> <span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTPS}<\/span> !=<span class=\"hljs-literal\" style=\"color: rgb(120, 169, 96);\">on<\/span>\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteRule<\/span><\/span> ^(.*)$ https:\/\/<span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span>\/<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">$1<\/span><span class=\"hljs-meta\" style=\"color: rgb(31, 113, 153);\"> [L,R=301]<\/span>\r\n\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteCond<\/span><\/span> <span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span> !^www\\.\r\n<span class=\"hljs-attribute\" style=\"font-weight: 700;\"><span class=\"hljs-nomarkup\">RewriteRule<\/span><\/span> ^(.*)$ https:\/\/www.<span class=\"hljs-variable\" style=\"color: rgb(188, 96, 96);\">%{HTTP_HOST}<\/span>\/<span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">$1<\/span><span class=\"hljs-meta\" style=\"color: rgb(31, 113, 153);\"> [R=301,L]<\/span><\/pre>\n<p>Here, we have discussed the most used rewrite rules and redirect URLs using HTACCESS. If you need any help regarding the <code>.htaccess<\/code> file, feel free to post your comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>.htaccess file is a configuration file used to override the main server configuration. .htaccess file placed in a directory and the configuration is applied to that particular directory and all the subdirectories. The most usage <\/p>\n","protected":false},"author":1,"featured_media":942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[77],"tags":[78,79,80],"class_list":["post-941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-htaccess","tag-htaccess","tag-rewriterule","tag-url-redirect","cat-77-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Redirect non-www to www &amp; HTTP to HTTPS using .htaccess file - CodexWorld<\/title>\n<meta name=\"description\" content=\"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP &amp; non-www requests to HTTPS &amp; www URL.\" \/>\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.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redirect non-www to www &amp; HTTP to HTTPS using .htaccess file - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP &amp; non-www requests to HTTPS &amp; www URL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-26T18:15:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-14T14:13:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"624\" \/>\n\t<meta property=\"og:image:height\" content=\"366\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Redirect non-www to www &#038; HTTP to HTTPS using .htaccess file\",\"datePublished\":\"2015-10-26T18:15:13+00:00\",\"dateModified\":\"2023-03-14T14:13:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/\"},\"wordCount\":397,\"commentCount\":13,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\",\"keywords\":[\"htaccess\",\"RewriteRule\",\"URL Redirect\"],\"articleSection\":[\"htaccess\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/\",\"name\":\"Redirect non-www to www & HTTP to HTTPS using .htaccess file - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\",\"datePublished\":\"2015-10-26T18:15:13+00:00\",\"dateModified\":\"2023-03-14T14:13:39+00:00\",\"description\":\"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP & non-www requests to HTTPS & www URL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png\",\"width\":624,\"height\":366,\"caption\":\"redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/redirect-non-www-to-www-http-to-https-using-htaccess-file\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redirect non-www to www &#038; HTTP to HTTPS using .htaccess file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Redirect non-www to www & HTTP to HTTPS using .htaccess file - CodexWorld","description":"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP & non-www requests to HTTPS & www URL.","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.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/","og_locale":"en_US","og_type":"article","og_title":"Redirect non-www to www & HTTP to HTTPS using .htaccess file - CodexWorld","og_description":"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP & non-www requests to HTTPS & www URL.","og_url":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-10-26T18:15:13+00:00","article_modified_time":"2023-03-14T14:13:39+00:00","og_image":[{"width":624,"height":366,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Redirect non-www to www &#038; HTTP to HTTPS using .htaccess file","datePublished":"2015-10-26T18:15:13+00:00","dateModified":"2023-03-14T14:13:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/"},"wordCount":397,"commentCount":13,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","keywords":["htaccess","RewriteRule","URL Redirect"],"articleSection":["htaccess"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/","url":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/","name":"Redirect non-www to www & HTTP to HTTPS using .htaccess file - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","datePublished":"2015-10-26T18:15:13+00:00","dateModified":"2023-03-14T14:13:39+00:00","description":"HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP & non-www requests to HTTPS & www URL.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","width":624,"height":366,"caption":"redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/redirect-non-www-to-www-http-to-https-using-htaccess-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Redirect non-www to www &#038; HTTP to HTTPS using .htaccess file"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/redirect-non-www-to-www-http-to-https-using-htaccess-file-by-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-fb","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=941"}],"version-history":[{"count":8,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/941\/revisions"}],"predecessor-version":[{"id":5290,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/941\/revisions\/5290"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/942"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}