Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Force Wordpress Server IP to redirect to domain name

I configured a Wordpress site in LAMP (only one site under /var/www/), including an ssl certificate, the domain works fine, with no cert issues,however, if i reach the website using its public IP I get an error for the cert:

Your connection is not private
NET::ERR_CERT_COMMON_NAME_INVALID

which makes sense, since the cert is generated for the domain name and not the IP. I tried adding the following rule using my public IP and domain name as suggested in other posts to force a redirect from IP to domain name within the .htaccess file but it did not help:

    RewriteEngine On                                                                                                                                                                                                                                                               
    RewriteCond %{HTTP_HOST} ^xx.xx.xx.xxx$ [OR]                                                                                                                                                                                                                                  
    RewriteRule (.*)$ http://example.com/$1 [R=301,L] 

I also tried the same on two virtual host files one on port 80 and 443:

    RewriteEngine On                                                                                                                                                                                                                                                               
    RewriteCond %{HTTP_HOST} ^xx\.xx\.xx\.xxx$ [OR]                                                                                                                                                                                                                                  
    RewriteRule (.*)$ http://example.com/$1 [R=301,L]

Any other suggestions ?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I finally found a solution, I used the following re-write condition in my htaccess file adding the IP :xx.xx..., and restarted apache:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^xx\.xx\.xx\.xx\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

I hope this helps future people who experience the same issue.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda