{"id":21701,"date":"2017-03-08T07:37:49","date_gmt":"2017-03-08T13:37:49","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=21701"},"modified":"2026-04-13T00:22:29","modified_gmt":"2026-04-13T05:22:29","slug":"how-to-redirect-http-traffic-to-https-in-nginx-and-apache","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/","title":{"rendered":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"size-full wp-image-21703 aligncenter\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\" alt=\"http to https\" width=\"1200\" height=\"600\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg 1200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-150x75.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-300x150.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-768x384.jpg 768w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-1024x512.jpg 1024w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-860x430.jpg 860w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-680x340.jpg 680w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-500x250.jpg 500w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-400x200.jpg 400w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-200x100.jpg 200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache-50x25.jpg 50w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>We will show you how to redirect HTTP traffic to HTTPS in <a href=\"https:\/\/www.rosehosting.com\/nginx-hosting.html\">Nginx<\/a> and <a href=\"https:\/\/www.rosehosting.com\/apache-hosting.html\">Apache<\/a>. You should always use HTTPS instead of HTTP to protect your website, even if it doesn&#8217;t handle sensitive communications. The main reasons to use HTTPS are:<\/p>\n<ul>\n<li><strong>Security<\/strong> &#8211; this is the main and most important reason to use HTTPS,\u00a0<span class=\"_Tgc\"> all communications between the visitor&#8217;s browser and the website are encrypted.<\/span><\/li>\n<li><strong>SEO <\/strong> &#8211; Google uses HTTPS as a ranking signal, which means that if your website is using\u00a0HTTPS it may get a certain boost in Google rankings.<\/li>\n<li><strong>Browser warnings &#8211;\u00a0<\/strong> if you are not using HTTPS, Google Chrome and other browsers will flag your site as &#8220;Not Secure&#8221;.<\/li>\n<li><strong>Trustworthiness<\/strong> &#8211; people usually trust a website much more if they have an SSL certificate.<\/li>\n<\/ul>\n<p>To use HTTPS, you&#8217;ll need an <a href=\"https:\/\/www.rosehosting.com\/ssl-certificates.html\">SSL Certificate<\/a>. You can <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting.html\">get a VPS from us<\/a> and we&#8217;ll install the certificate for you and properly configure Nginx\/Apache to redirect all traffic to HTTPS, free of charge.<\/p>\n<p><!--more--><\/p>\n<h2>1. Redirect HTTP to HTTPS using Apache mod_rewrite<\/h2>\n<p>To automatically redirect all your visitors to the HTTPS version of your site, add the following code in your site <code>.htaccess file<\/code><\/p>\n<pre>RewriteEngine On\r\n# redirect http to https\r\nRewriteCond %{HTTPS} off\r\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\r\n<\/pre>\n<p>If you want to redirect all your visitors to the <strong>HTTPS NON-WWW<\/strong> version of your, site use the following code:<\/p>\n<pre>RewriteEngine On\r\n# redirect all www to https non-www\r\nRewriteCond %{HTTP_HOST} ^www\\.(.*)$ [NC]\r\nRewriteRule ^(.*)$ https:\/\/%1\/$1 [L,R=301]\r\n# redirect http non-www to https non-www\r\nRewriteCond %{HTTPS} off\r\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\r\n<\/pre>\n<p>and to redirect all your visitors to the <strong>HTTPS WWW<\/strong> version of your site, use the following code:<\/p>\n<pre>RewriteEngine On\r\n# redirect all non-www to https www\r\nRewriteCond %{HTTP_HOST} !^www\\.(.*)$ [NC]\r\nRewriteRule ^(.*)$ https:\/\/www.%1\/$1 [L,R=301]\r\n# redirect http www to https www\r\nRewriteCond %{HTTPS} off\r\nRewriteRule ^(.*)$ https:\/\/www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\r\n<\/pre>\n<h2>2. Redirect HTTP to HTTPS with Nginx<\/h2>\n<p>We need to <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/\">create three server blocks<\/a>, one for HTTP, one for HTTPS NON-WWW and one for HTTPS WWW versions of the site. The first server block will redirect all visitors entering the site via HTTP to HTTPS and the two other blocks will redirect visitors entering the site via WWW to NON-WWW or vice-versa.<\/p>\n<p>To redirect all HTTP and HTTPS NON-WWW traffic to <strong>HTTPS WWW<\/strong>, use the following code:<\/p>\n<pre>server {\r\n  listen [::]:80;\r\n  listen 80;\r\n\r\n  server_name yourdomain.com www.yourdomain.com;\r\n\r\n  # redirect http to https www\r\n  return 301 https:\/\/www.yourdomain.com$request_uri;\r\n}\r\n\r\nserver {\r\n  listen [::]:443 ssl http2;\r\n  listen 443 ssl http2;\r\n\r\n  server_name yourdomain.com;\r\n\r\n  # SSL code\r\n\r\n  # redirect https non-www to https www\r\n  return 301 https:\/\/www.yourdomain.com$request_uri;\r\n}\r\n\r\nserver {\r\n\r\n  listen [::]:443 ssl http2;\r\n  listen 443 ssl http2;\r\n\r\n  server_name www.yourdomain.com;\r\n\r\n  # SSL code\r\n  # other code\r\n}\r\n<\/pre>\n<p>and to redirect all HTTP and HTTPS WWW traffic to <strong>HTTPS NON-WWW<\/strong>, use the following code:<\/p>\n<pre>server {\r\n  listen [::]:80;\r\n  listen 80\r\n\r\n  server_name yourdomain.com www.yourdomain.com;\r\n\r\n  # redirect http to https non-www\r\n  return 301 https:\/\/yourdomain.com$request_uri;\r\n}\r\n\r\nserver {\r\n  listen [::]:443 ssl http2;\r\n  listen 443 ssl http2;\r\n\r\n  server_name www.yourdomain.com;\r\n\r\n  # SSL code\r\n\r\n  # redirect https non-www to https www\r\n  return 301 https:\/\/yourdomain.com$request_uri;\r\n}\r\n\r\nserver {\r\n\r\nlisten [::]:443 ssl http2;\r\nlisten 443 ssl http2;\r\n\r\n  server_name yourdomain.com;\r\n\r\n  # SSL code\r\n  # Other code\r\n}\r\n<\/pre>\n<p>Don&#8217;t forget to replace &#8216;yourdomain.com&#8217; with your actual domain name.<\/p>\n<hr \/>\n<p>Of course, you don\u2019t have to\u00a0Redirect HTTP Traffic to HTTPS in Nginx and Apache if you use one of our <a href=\"https:\/\/www.rosehosting.com\">VPS Hosting services<\/a>, in which case you can simply ask our expert Linux admins to set this up for you. They are available 24&#215;7 and will take care of your request immediately.<\/p>\n<p><strong><span style=\"color: #ff0000;\">PS<\/span><\/strong>. If you liked this post, on\u00a0How to Redirect HTTP Traffic to HTTPS in Nginx and Apache,\u00a0 please share it with your friends on the social networks using the buttons below or simply leave a reply in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will show you how to redirect HTTP traffic to HTTPS in Nginx and Apache. You should always use HTTPS &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#more-21701\" aria-label=\"Read more about How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":21703,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1701,21,1707],"tags":[37,49,1529],"class_list":["post-21701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-networking-and-domains","category-tips-and-tricks","category-web-servers","tag-apache","tag-nginx","tag-redirect","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting<\/title>\n<meta name=\"description\" content=\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting\" \/>\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.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\" \/>\n<meta property=\"og:description\" content=\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-08T13:37:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-13T05:22:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\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.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\",\"datePublished\":\"2017-03-08T13:37:49+00:00\",\"dateModified\":\"2026-04-13T05:22:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/\"},\"wordCount\":445,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\",\"keywords\":[\"apache\",\"nginx\",\"redirect\"],\"articleSection\":[\"Networking and Domains\",\"Tips and Tricks\",\"Web Servers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/\",\"name\":\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\",\"datePublished\":\"2017-03-08T13:37:49+00:00\",\"dateModified\":\"2026-04-13T05:22:29+00:00\",\"description\":\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg\",\"width\":1200,\"height\":600,\"caption\":\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting","description":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting","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.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/","og_locale":"en_US","og_type":"article","og_title":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache","og_description":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2017-03-08T13:37:49+00:00","article_modified_time":"2026-04-13T05:22:29+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache","datePublished":"2017-03-08T13:37:49+00:00","dateModified":"2026-04-13T05:22:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/"},"wordCount":445,"commentCount":4,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg","keywords":["apache","nginx","redirect"],"articleSection":["Networking and Domains","Tips and Tricks","Web Servers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/","name":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg","datePublished":"2017-03-08T13:37:49+00:00","dateModified":"2026-04-13T05:22:29+00:00","description":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache | RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/03\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache.jpg","width":1200,"height":600,"caption":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-redirect-http-traffic-to-https-in-nginx-and-apache\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Redirect HTTP Traffic to HTTPS in Nginx and Apache"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=21701"}],"version-history":[{"count":2,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21701\/revisions"}],"predecessor-version":[{"id":51845,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21701\/revisions\/51845"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/21703"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=21701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=21701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=21701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}