{"id":311,"date":"2018-10-17T22:10:45","date_gmt":"2018-10-17T22:10:45","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/?p=311"},"modified":"2018-10-17T22:10:45","modified_gmt":"2018-10-17T22:10:45","slug":"forceful-redirect-from-http-to-https","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/","title":{"rendered":"Forceful redirect from HTTP to HTTPS"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"172\" data-attachment-id=\"312\" data-permalink=\"https:\/\/www.24x7serversupport.com\/blog\/image\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?fit=467%2C172&amp;ssl=1\" data-orig-size=\"467,172\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?fit=300%2C110&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?fit=467%2C172&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png?resize=467%2C172&#038;ssl=1\" alt=\"\" class=\"wp-image-312\" srcset=\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?w=467&amp;ssl=1 467w, https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?resize=300%2C110&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?resize=260%2C96&amp;ssl=1 260w, https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?resize=50%2C18&amp;ssl=1 50w, https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2018\/10\/image.png?resize=150%2C55&amp;ssl=1 150w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx<\/h2>\n\n\n\n<p>Below method can be used when you wish all configured sites to definitely only use&nbsp;<code>https:<\/code><\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">server {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listen 80 <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default_server; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_name _; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 301 https:\/\/$host$request_uri; <br \/>} <code><\/code><\/p>\n\n\n\n<p>\n\nWe can redirect only specific sites also. This is better if you have multiple apps\/sites and not all of them should be forced to use SSL certificates.\n\n<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">server { <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listen 80; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_name yourdomain.com; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 301 https:\/\/$server_name$request_uri; <br \/>}<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apache<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">Redirect HTTP to HTTPS on Apache Using .htaccess File<\/h4>\n\n\n\n<p>\n\nFor this method, make sure&nbsp;<strong>mod_rewrite<\/strong>&nbsp;is enabled\n\n<\/p>\n\n\n\n<p>Once it is enabled, you can just add below lines to .htaccess in your domain&#8217;s document root directory:<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">RewriteEngine On <br \/>RewriteCond %{HTTPS} !=on <br \/>RewriteRule ^\/?(.*) https:\/\/%{SERVER_NAME}\/$1 [R,L]<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Redirect HTTP to HTTPS on Apache Virtual Host<\/h4>\n\n\n\n<p>\n\nTo redirect HTTP to HTTPS for all the pages of your website, first open the appropriate virtual host file. Then modify it by adding the configuration below.\n\n<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\">NameVirtualHost *:80 <br \/>&lt;VirtualHost *:80&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; ServerName www.yourdomain.com <strong><br \/>&nbsp;&nbsp;&nbsp;&nbsp; Redirect \/ https:\/\/www.yourdomain.com<\/strong> <br \/>&lt;\/VirtualHost&gt; <br \/>&lt;VirtualHost _default_:443&gt; <br \/>&nbsp;&nbsp;&nbsp; ServerName www.yourdomain.com <br \/>&nbsp;&nbsp;&nbsp; DocumentRoot \/usr\/local\/apache2\/htdocs <br \/>&nbsp;&nbsp;&nbsp; SSLEngine On <br \/>&lt;\/VirtualHost&gt;<\/p>\n\n\n\n<p>\n\nSave and close the file, then restart the HTTP sever\n\n<\/p>\n\n\n\n<p class=\"has-background has-very-light-gray-background-color\"># sudo systemctl restart apache2 [Ubuntu\/Debian OS] <br \/># systemctl restart httpd [RHEL\/CentOS OS]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx Below method can be used when you wish all configured sites to definitely only use&nbsp;https: server {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listen 80 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default_server; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_name _; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 301 https:\/\/$host$request_uri; } We can redirect only specific sites also. This is better if you have multiple apps\/sites and not all of them should be forced to use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[30],"tags":[43,44,45,46],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-centos","tag-http","tag-http-to-https","tag-https","tag-to"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to forcefully redirect HTTP traffic to HTTPS<\/title>\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.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to forcefully redirect HTTP traffic to HTTPS\" \/>\n<meta property=\"og:description\" content=\"Nginx Below method can be used when you wish all configured sites to definitely only use&nbsp;https: server {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listen 80 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default_server; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_name _; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 301 https:\/\/$host$request_uri; } We can redirect only specific sites also. This is better if you have multiple apps\/sites and not all of them should be forced to use [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-17T22:10:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. 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.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/\",\"name\":\"How to forcefully redirect HTTP traffic to HTTPS\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png\",\"datePublished\":\"2018-10-17T22:10:45+00:00\",\"dateModified\":\"2018-10-17T22:10:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage\",\"url\":\"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png\",\"contentUrl\":\"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Forceful redirect from HTTP to HTTPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to forcefully redirect HTTP traffic to HTTPS","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.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/","og_locale":"en_US","og_type":"article","og_title":"How to forcefully redirect HTTP traffic to HTTPS","og_description":"Nginx Below method can be used when you wish all configured sites to definitely only use&nbsp;https: server {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listen 80 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default_server; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server_name _; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 301 https:\/\/$host$request_uri; } We can redirect only specific sites also. This is better if you have multiple apps\/sites and not all of them should be forced to use [&hellip;]","og_url":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/","og_site_name":"24x7serversupport Blog","article_published_time":"2018-10-17T22:10:45+00:00","og_image":[{"url":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/","url":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/","name":"How to forcefully redirect HTTP traffic to HTTPS","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage"},"thumbnailUrl":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png","datePublished":"2018-10-17T22:10:45+00:00","dateModified":"2018-10-17T22:10:45+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#primaryimage","url":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png","contentUrl":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/wp-content\/uploads\/2018\/10\/image.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/forceful-redirect-from-http-to-https\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Forceful redirect from HTTP to HTTPS"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":0,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}