Im using MERN stack to build a web app. and its being hosted on a vps, and connected to a domain name. the problem is that there is two versions of the app. one on the ip adress of the vps and the other on the domain name. and this is not good for SEO. and i cant seem to find good resources on ip canonicalization or rediercting to domain name.
normally on an apache server i would use .htaccess but thats for apache. is there an equvialnt to .htaccess for expressjs. ? or any other way i can achive that.
thank you.
express
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!
Hello,
What I would usually do is to use Nginx as a reverse proxy. This will also allow you to install an SSL certificate for your website using Let’s Encrypt and certbot.
You can follow the steps on how to do that here:
Once Nginx is in place, you could use the following server block to do the IP to domain redirection:
server {
listen 80;
server_name your_ip;
return 302 $scheme://yourdomain.com$request_uri;
}
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.