How to access site through IP address?



  • To access websites and web apps through IP address, when there is no domain pointed to the server, the easy option on shared hosts (e.g. cPanel/CentOS) would be:

    Apache mod_userdir Tweak

    https://serverIPaddress/~cpanelusername

    A "Temporary Webpage URL" which you can use to access your website until your DNS resolves in the form of https://serverIPaddress/~account. This requires however mod_userdir access to be enabled, see Apache mod_userdir Tweak.

    An issue with mod_userdir that certain hosts won't allow it and certain configurations won't work (e.g. WordPress, Joomla, etc.), where the system will look for the domain set in config files. For that reason, the right option would be:

    Using the “hosts” file

    Used to map domains (hostnames) to IP addresses. Using the hosts file you can change the IP address that you resolve a given domain name to that only affects your own computer. This can be very handy, when you wish to see how a website will look like, before making any DNS changes.

    Find the hosts file, on your OS:

    Windows: C:\Windows\System32\drivers\etc\hosts

    SystemRoot > System32\drivers\etc\hosts

    Linux: /etc/hosts
    macOS: /private/etc/hosts

    Open up the hosts file with a text editor (make sure you have write permissions) and add the following line:

    000.000.000.000 yourdomain.com www.yourdomain.com

    *where the first is your IP address, followed by the desired domain name, both with and without www.

    Linux: sudo nano /etc/hosts
    Mac: sudo nano /private/etc/hosts
    Windows: Notepad and open C:\Windows\System32\Drivers\etc\hosts


Log in to reply
 

© 2108 H7 | Powered by NodeBB

Looks like your connection to H7 was lost, please wait while we try to reconnect.