Redirect Ip To Domain

Posted September 3, 2013 10.6k views
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?

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
3 answers
Edit /etc/apache2/sites-enabled/000-default and set DocumentRoot to /dev/null.

Add this line:

Redirect /

Finally, restart apache:

sudo service apache2 restart
@robert_h_boy: Create a virtualhost for the IP address:

Replace with your IP address, and with your actual domain name you want to redirect to.