Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
¿Existe un método de redireccionamiento https uniforme que debería funcionar tanto para cPanel como para VestaCP cuando apache htpasswd está habilitado?

Opero sitios web que se ejecutan tanto en VestaCP como en cPanel. Mientras desarrollaba los sitios, configuré la protección htpassword, la sintaxis de la contraseña es así:

 AuthType Basic AuthUserFile /home/the-account/htpasswd AuthName "Restricted" Require valid-user

Para la redirección para que todo redirija a https://www.the-website... Yo uso:

 RewriteEngine on RewriteBase / Options +FollowSymlinks # Redirect http to https RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.website.ext$1 [R,L]

Las líneas de redirección funcionan perfectamente si la protección con contraseña no está habilitada. Todo:

 website.ext www.website.ext http://website.ext

redirigir a:

 https://www.website.ext (the goal)

Sin embargo, el comportamiento es diferente en VestaCP frente a cPanel y se rompe severamente en cPanel. En vesta, cuando visita la url como website.ext, muestra la pantalla de inicio de sesión de apache y primero debe iniciar sesión como http:// y luego una segunda vez como https://www. pero funciona y terminas en la meta.

Con cPanel se rompe. Si intenta iniciar sesión como cualquiera de esas URL no calificadas, terminará en un tiempo de espera, página no encontrada, algo así como:

 www.website.ext401.shtml.

La ext y 401.html se ejecutan juntas como se ve arriba. El error de la página principal es: No se puede acceder al sitio. Si intenta iniciar sesión como https://www.website.ext , funciona perfectamente.

Es importante solucionar el problema de cPanel, VestaCP estaría bien.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Con la gran ayuda de un amigo contratista, aquí está la solución que se nos ocurrió y que configuré en varios sitios web en vivo y en desarrollo (acceso restringido):

La línea del documento de error en la primera línea del archivo resuelve el problema "ErrorDocument 401" en cPanel cuando la restricción de contraseña de Apache está habilitada

 $website.$ext ==> your-website.com $account ==> account folder of the home directory where the htpasswd file is stored; /home/home-folder

-------------- recorte ---------------

 ErrorDocument 401 default # Redirect http to https RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ https://www.$website.$ext/$1 [L,R=301] # BEGIN-APACHE-RESTRICTION <If " %{HTTPS} != 'off' && %{HTTP_HOST} == 'www.$website.$ext'"> AuthType Basic AuthUserFile /home/$account/htpasswd AuthName "restricted area" Require valid-user </If> # END-APACHE-RESTRICTION
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!