Question

If someone goes to port 80 of my droplet, I would like them to be redirected to my business website. How can I set that up?

Posted July 26, 2017 1.2k views
NetworkingUbuntu 16.04

Ubuntu 16.04.02 x64

Redirect to www.apollos-dev.com

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.

×
2 answers

Redirex looks like it will do what you need in place of a full web server. I haven’t tried it myself, but it looks in line with your needs.

Also, a 301 redirect would be a better choice. Meta redirects are slower, break the web browsers ‘back’ button and can have negative SEO implications.

  • Thanks for the info. I set up lighttpd to do a 301 redirect.

    For anyone that is interested, I added the following lines to the end of /etc/lighttpd/lighttpd.conf

    $HTTP["host"] == "thishost.mydomain.com" {
      url.redirect  = (
        "^/(.*)" => "http://www.mydomain.com/$1",
      )
    }
    
    $HTTP["host"] == "this.ip.address" {
      url.redirect  = (
        "^/(.*)" => "http://www.mydomain.com/$1",
      )
    }
    
    

I answered my own question.

I installed lighttpd, opened port 80 in the firewall, edited /var/www/html/index.lighttpd.html so that it contained the following:

<html>
<head>
<meta http-equiv="refresh" content="0; URL='http://mydomain.com'" />
</head>
<body>
</body>
</html>

… and I’m good to go. If there is another way of doing it without using the minimal resources that lighttpd uses, please let me know.

Submit an Answer