Curl: (51) error when trying to check whether or not my website redirects correctly

14,893

Your ssl certificate is propably self-signed, try using curl with the -k (--insecure) option which disables ssl verification.

Share:
14,893

Related videos on Youtube

Strazz
Author by

Strazz

Updated on June 04, 2022

Comments

  • Strazz
    Strazz almost 2 years

    When I try to make up a .htaccess file to redirect my www to non-www, I get some issues.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    

    This is the .htaccess file I've used, after using: curl -I https://www I get:

    curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

    But after using curl -I http://www I get a 301 redirection, which was my intended case but it redirects to HTTPS www.

    The problem of that is that I get a DNS error when I'm visiting it on the internet.

    How can I possibly fix this?

    • MrWhite
      MrWhite over 6 years
      Did you implement HSTS?
    • Strazz
      Strazz over 6 years
      I did indeed do that.
  • Strazz
    Strazz over 6 years
    That seems to give me the right info, but how can I then counter the NET::ERR_CERT_COMMON_NAME_INVALID from Chrome?