Skip to main content

CPANEL-40585 - Force HTTPS on password-protected directory

Comments

6 comments

  • cPRex Jurassic Moderator
    Hey there! I believe this is due to the order of your configuration. The Apache includes will get read before the local .htaccess with your example. However, if you use the cPanel >> Directory Privacy tool, that creates a local .htaccess inside the specific directory you're protecting with the following code: #----------------------------------------------------------------cp:ppd # Section managed by cPanel: Password Protected Directories -cp:ppd # - Do not edit this section of the htaccess file! -cp:ppd #----------------------------------------------------------------cp:ppd AuthType Basic AuthName "Protected 'public_html/privacytest'" AuthUserFile "/home/username/.htpasswds/public_html/privacytest/passwd" Require valid-user #----------------------------------------------------------------cp:ppd # End section managed by cPanel: Password Protected Directories -cp:ppd #----------------------------------------------------------------cp:ppd
    Doing that instead of using the Apache include system will likely get things working how you expect.
    0
  • msklut
    I gave that a try, but it still doesn't redirect to HTTPS when I access that directory.
    0
  • cPRex Jurassic Moderator
    I did some additional testing on my end and confirmed this isn't working as intended. I've created case CPANEL-40585 for our developers to look into this, and you can follow along with that case here:
    0
  • msklut
    Based on Apache 2.4, would this be the preferred 'HTTPS redirect' method? NameVirtualHost *:80 ServerName www.yourdomain.com Redirect / https://www.yourdomain.com
    0
  • cPRex Jurassic Moderator
    I always perform the redirect inside the .htaccess file. For other pieces of software, such as WordPress, you may need a plugin like ReallySimpleSSL or similar to ensure the WordPress structure is redirected properly. That is the correct format for an Apache redirect, although many people prefer to use " Redirect permanent / Example Domain" as the last line. With a cPanel-based machine though, remember you can't edit the Apache configuration directly.
    0
  • msklut
    This method worked:
    0

Please sign in to leave a comment.