Redirecting IP Address to the domain name on Apache and nginx

redirecting-ip--domain-name-apache-nginx

Redirecting IP Address to the domain name on Apache and nginx

Normally when you host your domain (website) name on a dedicated IP Address.
The dedicated IP will also server the same content as the domain name.

To resolve this issue, we are going to use the .htaccess in Apache and nginx config

apacheOn Apache, use the Below .htaccess code.

change the earneasy.net with your domain name.

On the Above .htaccess eg code, your dedicated IP is : 192.168.192.1 and target redirecting domain name is www.earneasy.net

If you want to redirect any URL from http://ipaddress\subfolder, Just add $ at the end of the IP like below.

nginxOn nginx, use the Below  configuration method
On the nginx, we cannot used the same method of .htaccess because of its operating method.
First, find the file & path of the ngnix configuration file.

Normally found in
/etc/nginx/sites-available/domainname.com

use nano or vi editor

and add the below codes in the very bottom of the configuration file. make sure change necessary changes that matches your domain name & IP Address

Just save the file and make sure you restart the ngnix to apply the configurations.

I hope this helps few, if you find any mistakes or corrections, Please do drop us a message.
The above methods are tested personally by me and working 100 Percentage.

Do visit again for more Updates.

About Bindhu Maniya

Software Engineer at TCS Chennai, Studied Software Engineering at RMK Engineering College, DAV School, Chennai Lives in Chennai, Tamil Nadu, Love to write blogs & helping technically to my friends who needs it. like you :)

View all posts by Bindhu Maniya →

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.