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

202
Views
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 answers
Answer question

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 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!