How to redirect Server Ip to www.Domain name?

saz99

New Member
#1
I am using Openlitespeed WordPress on Ubuntu 20.04 (digital ocean market place OpenLitespeed WordPress stack). Even after connecting domain, My website is accessible through the IP address.

Is there a way to redirect IP and [ip/(post-slug)] to my domain and [https://www.(my-domain)/(post-slug)] ? I don't have any coding/programming skills.

Thank you.
 

Cold-Egg

Administrator
#2
Please check your wordpress home and site URL are set to www domain.
If you setup wordpress site with www domain, then it should auto redirect IP to the www domain without extra configuration.
 

saz99

New Member
#3
Well, it wasn't I had to manually write it in the.htacess file. The domain was redirecting to www with no issues but the IP to the domain was not working.
 

Cold-Egg

Administrator
#4
Hi,

How about
Code:
RewriteCond %{HTTP_HOST} ^12\.34\.56\.789$
RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301]
Remember to restart web server
Code:
service lsws restart
Best
 
Top