How To i Redirect My ip address to My domain

Posted January 22, 2016 11.6k views
NginxUbuntuDigitalOceanConfiguration Management

Hello Friends When any one Type my IP Address Like on browser address bar then my main site is show i want to redirect my ip address to main domain name i’m using Ubuntu and vesta cp panel any one can tell me how can i redirect my domain name to my website…

Thanks in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

You can do that via the Web Server configuration files.

If using Apache, you would need to add this to your configuration setup:


If using Nginx, you would need to add this to your configuration setup:


Please remember you would need to restart the Web Server after making such changes. For more information on setting that up, you might want to read our guides on Setting up Apache VirtualHosts and Setting up Nginx Server Blocks.

Also please note if you are using a CMS, such as WordPress or Magento, you would need to edit the database entries that determine the site/home URLs. You can normally do this via the CMS admin panel, or directly via MySQL.

Hope it helps!
Jason Colyer
DigitalOcean Platform Support Lead

by Justin Ellingwood
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.

With NGINX, you can edit nginx configuration file
add this code
server {
listen 80;
301 redirect$request