{"id":1171,"date":"2021-10-19T22:54:48","date_gmt":"2021-10-20T02:54:48","guid":{"rendered":"https:\/\/www.neothek.com\/soporte\/?post_type=kb&#038;p=1171"},"modified":"2022-04-28T17:46:01","modified_gmt":"2022-04-28T21:46:01","slug":"como-forzar-https-usando-htaccess","status":"publish","type":"kb","link":"https:\/\/www.neothek.com\/soporte\/articulo\/como-forzar-https-usando-htaccess\/","title":{"rendered":"C\u00f3mo forzar HTTPS usando .htaccess"},"content":{"rendered":"<p style=\"text-align: justify;\"><span class=\"\">Despu\u00e9s de instalar un certificado SSL, su sitio web est\u00e1 disponible a trav\u00e9s de HTTP y HTTPS.\u00a0<\/span>Sin embargo, es mejor usar solo el \u00faltimo porque cifra y protege los datos de su sitio web.\u00a0Si bien <a href=\"https:\/\/www.neothek.com\/\">Neothek<\/a> permite a los usuarios configurar esta configuraci\u00f3n con solo un clic, tambi\u00e9n puede usar el\u00a0archivo\u00a0<strong>.htaccess<\/strong> para forzar la conexi\u00f3n segura HTTPS. Este tutorial le mostrar\u00e1 c\u00f3mo.<\/p>\n<h2 style=\"text-align: justify;\"><span class=\"goog-text-highlight\">Forzar HTTPS en todo el tr\u00e1fico<\/span><\/h2>\n<p style=\"text-align: justify;\">Una de las muchas funciones que puede realizar a trav\u00e9s de\u00a0<strong>.htaccess<\/strong>\u00a0son las redirecciones 301, que redirigen permanentemente una URL antigua a una nueva.\u00a0Puede activar la funci\u00f3n para forzar HTTPS en todo el tr\u00e1fico entrante siguiendo estos pasos:<\/p>\n<p style=\"text-align: justify;\">1. Vaya al\u00a0 <strong>Administrador de archivos\u00a0<\/strong>\u00a0en su panel de alojamiento y abra\u00a0<strong>.htaccess\u00a0<\/strong> que se encuentra dentro de la carpeta <strong>\u00abpublic_html\u00bb<\/strong>.\u00a0Si no puede localizarlo, aseg\u00farese de\u00a0crearlo o mostrarlo\u00a0.<\/p>\n<p style=\"text-align: justify;\">2. Despl\u00e1cese hacia abajo para encontrar <strong>RewriteEngine On<\/strong>\u00a0\u00a0e inserte las siguientes l\u00edneas de c\u00f3digo debajo de \u00e9l:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">RewriteEngine On \r\nRewriteCond %{HTTPS} off \r\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/pre>\n<p style=\"text-align: justify;\">3. <strong>Guarde<\/strong>\u00a0\u00a0los cambios.<\/p>\n<p style=\"text-align: justify;\"><span class=\"mkb-shortcode-container\">\t\t<div class=\"mkb-warning\">\n\t\t\t<div class=\"mkb-warning__icon\">\n\t\t\t\t<i class=\"fa fa-exclamation-triangle fa-lg\"><\/i>\n\t\t\t<\/div>\n\t\t\t<div class=\"mkb-warning__content\">\n\t\t\t\tIMPORTANTE: aseg\u00farese de que la l\u00ednea\u00a0\u00a0<strong>RewriteEngine On<\/strong>\u00a0no se repita dos veces.\u00a0En caso de que la l\u00ednea ya exista, simplemente copie el resto del c\u00f3digo sin ella.\t\t\t<\/div>\n\t\t<\/div>\n\t<\/span>\n<h2 style=\"text-align: justify;\"><span class=\"\">Forzar HTTPS en un dominio espec\u00edfico<\/span><\/h2>\n<p style=\"text-align: justify;\">Supongamos que tiene dos dominios:\u00a0<strong>http:\/\/midominio1.com <\/strong>\u00a0y\u00a0\u00a0<strong>http:\/\/midominio2.com. <\/strong>Ambos dominios acceden al mismo sitio web, pero solo desea que el primero sea redirigido a la versi\u00f3n HTTPS.\u00a0En este caso, debe utilizar el siguiente c\u00f3digo:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">RewriteEngine On \r\nRewriteCond% {HTTP_HOST} ^midominio1.com [ NC ] \r\nRewriteCond% {HTTPS} off\r\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI}\u00a0[R=301,L]<\/pre>\n<p style=\"text-align: justify;\">Aseg\u00farese de reemplazar\u00a0<strong>yourdomain1<\/strong>\u00a0con el dominio real en el que est\u00e1 intentando forzar HTTPS.<\/p>\n<h2 style=\"text-align: justify;\">Forzar HTTPS en una carpeta espec\u00edfica<\/h2>\n<p style=\"text-align: justify;\">El\u00a0archivo\u00a0<strong>.htaccess\u00a0<\/strong>\u00a0tambi\u00e9n se puede utilizar para forzar HTTPS en carpetas espec\u00edficas.\u00a0Sin embargo, el archivo debe colocarse en la carpeta que tendr\u00e1 la conexi\u00f3n HTTPS.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">RewriteEngine On \r\nRewriteCond %{HTTPS} off \r\nRewriteRule ^(folder1|folder2|folder3) https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre>\n<p style=\"text-align: justify;\">Aseg\u00farese de cambiar las\u00a0referencias de\u00a0<strong>carpeta<\/strong>\u00a0a los nombres de directorio reales.<\/p>\n<p style=\"text-align: justify;\">Despu\u00e9s de realizar los cambios, borre la memoria cach\u00e9 de su navegador e intente conectarse a su sitio a trav\u00e9s de HTTP.\u00a0Si todo se agreg\u00f3 correctamente, el navegador lo redireccionar\u00e1 a la versi\u00f3n HTTPS.<\/p>\n<h2 style=\"text-align: justify;\">Conclusi\u00f3n<\/h2>\n<p style=\"text-align: justify;\">\u00a1Felicidades!\u00a0ha editado correctamente su\u00a0<strong>archivo .htaccess<\/strong> y ha redirigido todo el tr\u00e1fico HTTP a HTTPS, la versi\u00f3n segura de su sitio web. Dependiendo de la plataforma donde desarroll\u00f3 su sitio web, podr\u00eda haber m\u00e9todos alternativos para habilitar esta funci\u00f3n. Por ejemplo, puede configurar su sitio de WordPress o PrestaShop para que funcione con HTTPS utilizando complementos o plugins.<\/p>\n<p style=\"text-align: justify;\">Si tiene alg\u00fan consejo, truco o sugerencia que quiera compartir, \u00a1esperamos verlo en los comentarios.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Despu\u00e9s de instalar un certificado SSL, su sitio web est\u00e1 disponible a trav\u00e9s de HTTP y HTTPS.\u00a0Sin embargo, es mejor usar solo el \u00faltimo porque cifra y protege los datos de su sitio web.\u00a0Si bien Neothek permite a los usuarios configurar esta configuraci\u00f3n con solo un clic, tambi\u00e9n puede usar el\u00a0archivo\u00a0.htaccess para forzar la conexi\u00f3n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"kbtopic":[13],"kbtag":[39,42,40,41],"class_list":["post-1171","kb","type-kb","status-publish","hentry","kbtopic-web-hosting","kbtag-forzar-https","kbtag-htaccess","kbtag-https","kbtag-ssl"],"_links":{"self":[{"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kb\/1171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/comments?post=1171"}],"version-history":[{"count":5,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kb\/1171\/revisions"}],"predecessor-version":[{"id":1682,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kb\/1171\/revisions\/1682"}],"wp:attachment":[{"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/media?parent=1171"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kbtopic?post=1171"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.neothek.com\/soporte\/wp-json\/wp\/v2\/kbtag?post=1171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}