Redirect Ip To Domain

Hi there! I’m using apache web server on Ubuntu and I need to disable the ability for people to access the website by using the server’s IP address in a web browser. I want it so that when someone attempts to browse to the IP address they get Redirect to the domain.

I tried to google it, I found few tutorials, but they dont work for me.

What configurations would be necessary to do that?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Edit <code>/etc/apache2/sites-enabled/000-default</code> and set DocumentRoot to <code>/dev/null</code>. <br> <br>Add this line: <br> <br><pre>Redirect /</pre> <br>Finally, restart apache: <br> <br><pre>sudo service apache2 restart</pre>

@robert_h_boy: Create a virtualhost for the IP address: <br><a href=“”></a> <br> <br>Replace with your IP address, and with your actual domain name you want to redirect to.

what about for nginx?