{"id":8710,"date":"2014-11-09T19:33:42","date_gmt":"2014-11-09T19:33:42","guid":{"rendered":"https:\/\/wp.okra.host\/article\/forcing-http-redirect-to-ssl\/"},"modified":"2021-03-07T21:27:03","modified_gmt":"2021-03-07T20:27:03","slug":"forcing-http-redirect-to-ssl","status":"publish","type":"ht_kb","link":"https:\/\/kb.okra.host\/de\/article\/forcing-http-redirect-to-ssl\/","title":{"rendered":"HTTP-Umleitung auf SSL erzwingen"},"content":{"rendered":"<h2 id=\"overview\" >Overview<\/h2>\n<p>Converting HTTP to HTTPS resources can be accomplished in several ways. It goes without saying that you should setup and test your SSL certificate before performing any of the following methods.<\/p>\n<h3 id=\"strict-transport-security\" >Strict Transport Security<\/h3>\n<p>Modern browsers support a security standard called \u201c<a href=\"https:\/\/en.wikipedia.org\/wiki\/HTTP_Strict_Transport_Security\">HTTP Strict Transport Security<\/a>\u201c, or HSTS for short. HSTS sends a header with the URI response to indicate that future requests should use HTTPS.<\/p>\n<p>To utilize HSTS, add the following line to a <a href=\"https:\/\/kb.okra.host\/guides\/htaccess-guide\/\">.htaccess<\/a> in the <a href=\"https:\/\/kb.okra.host\/web-content\/where-is-site-content-served-from\/\">document root<\/a> of the domain\/subdomain:<\/p>\n<pre><code>Header always set Strict-Transport-Security \"max-age=63072000;\"\r\n<\/code><\/pre>\n<p>The above example restricts mandatory SSL for the domain only. To extend this policy to subdomains as well, such as forum.example.com and blog.example.com, add \u201cincludeSubdomains\u201d:<\/p>\n<pre><code>Header always set Strict-Transport-Security \"max-age=63072000; includeSubdomains;\"<\/code><\/pre>\n<p><span style=\"color: #ff0000;\"><strong>Downsides:<\/strong>\u00a0<span style=\"color: #000000;\">first request if sent over HTTP will not be encrypted, requires browser compliance<\/span><\/span><\/p>\n<p><span style=\"color: #339966;\"><strong>Upsides:\u00a0<\/strong><span style=\"color: #000000;\">easy to implement, SSL can propagate to subdomains, directive is cached in browser<\/span><\/span><\/p>\n<h3 id=\"mod_rewrite-rewrite\" >mod_rewrite Rewrite<\/h3>\n<p>By utilizing <a href=\"http:\/\/httpd.apache.org\/docs\/current\/mod\/mod_rewrite.html\">mod_rewrite<\/a>, add the following to a <a href=\"https:\/\/kb.okra.host\/guides\/htaccess-guide\/\">.htaccess<\/a> file in the <a href=\"https:\/\/kb.okra.host\/web-content\/where-is-site-content-served-from\/\">document root<\/a> of the domain\/subdomain that you would like to redirect:<\/p>\n<pre>RewriteEngine On\r\nRewriteBase \/\r\nRewriteCond %{HTTPS} !^on$\r\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}\/$1 [R,L]<\/pre>\n<p><span style=\"color: #ff0000;\"><strong>Downsides:<\/strong>\u00a0<span style=\"color: #000000;\">can be complex, does not extend to subdomains without a common parent directory, can create a redirect loop<\/span><\/span><\/p>\n<p><span style=\"color: #339966;\"><strong>Upsides:\u00a0<\/strong><span style=\"color: #000000;\">extremely flexible implementation<\/span><\/span><\/p>\n<h3 id=\"wordpress\" >WordPress<\/h3>\n<p>WordPress creates absolute URIs. If WordPress is installed over http:\/\/, then all URIs will reflect http:\/\/. To convert generated URIs from http:\/\/ to https:\/\/, login to the WordPress <a href=\"https:\/\/kb.okra.host\/wordpress\/access-wordpress-admin-panel\/\">administrative panel<\/a>, go to <strong>Settings<\/strong> &gt; <strong>General<\/strong>. Change both the WordPress Address and Site Address fields from http:\/\/\u2026 to https:\/\/\u2026 If not all links, such as old posts, have changed correctly, use a third-party plugin such as <a href=\"https:\/\/wordpress.org\/plugins\/really-simple-ssl\/\">Really Simple SSL<\/a>\u00a0to update all post data.<\/p>\n<div id=\"attachment_1427\" class=\"wp-caption aligncenter\" style=\"width: 310px;\">\n<p><a href=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2014\/11\/wordpress-ssl.png\" rel=\"lightbox-0\" data-lbwps-width=\"782\" data-lbwps-height=\"172\" data-lbwps-srcsmall=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2014\/11\/wordpress-ssl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1427\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2014\/11\/wordpress-ssl-300x66.png\" alt=\"\" width=\"300\" height=\"66\" aria-describedby=\"caption-attachment-1427\" \/><\/a><\/p>\n<p id=\"caption-attachment-1427\" class=\"wp-caption-text\">WordPress SSL tunables<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview Converting HTTP to HTTPS resources can be accomplished in several ways. It goes without saying that you should setup and test your SSL certificate before performing any of the following methods. Strict Transport Security Modern browsers support a security standard called \u201cHTTP Strict Transport Security\u201c, or HSTS for short&#8230;.<\/p>","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[67],"ht-kb-tag":[],"class_list":["post-8710","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-ssl"],"_links":{"self":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/comments?post=8710"}],"version-history":[{"count":2,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8710\/revisions"}],"predecessor-version":[{"id":8825,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8710\/revisions\/8825"}],"wp:attachment":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media?parent=8710"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-category?post=8710"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-tag?post=8710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}