{"id":377,"date":"2021-07-23T12:28:45","date_gmt":"2021-07-23T12:28:45","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/how-to-modify-your-hosts-file\/"},"modified":"2021-07-23T12:28:45","modified_gmt":"2021-07-23T12:28:45","slug":"how-to-modify-your-hosts-file","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/how-to-modify-your-hosts-file\/","title":{"rendered":"How to Modify Your Hosts File"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>Your hosting provider may offer you a temporary URL in the <code>http:\/\/IP\/~username<\/code> format (where <code>IP<\/code> represents the server\u2019s IP address and <code>username<\/code> represents the cPanel account name) to access your website. This is useful, for example, if you migrate your website to a new server and want to test the site before you point the DNS records to it.<\/p>\n<p>However, some sites will <strong>not<\/strong> work with a temporary URL. For those sites, you can configure your workstation with the server\u2019s IP address. To do this, modify your workstation\u2019s <code>\/etc\/hosts<\/code> file to use the server\u2019s domain name and IP address.<\/p>\n<p>This document explains how to modify your workstation\u2019s <code>\/etc\/hosts<\/code> file.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>Hosting providers can use the WHM\u2019s <em>Apache mod_userdir Tweak<\/em> interface (_WHM &gt;&gt; Home &gt;&gt; Security Center &gt;&gt; Apache mod<em>userdir Tweak<\/em>) to offer their customers a temporary URL.<\/p>\n<\/p><\/div>\n<\/div>\n<h2 id=\"modify-the-hosts-file\">Modify the hosts file<\/h2>\n<p>The following methods allow you to modify your workstation\u2019s <code>\/etc\/hosts<\/code> file.<\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<p>Your workstation\u2019s operating system will <strong>not<\/strong> remove your changes to the <code>\/etc\/hosts<\/code> file. If you want the domain that you added to use public DNS entries, you <strong>must<\/strong> manually remove the domain name and IP address in the <code>\/etc\/hosts<\/code> file.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"macos-and-linux\">macOS\u00ae and Linux\u00ae<\/h3>\n<p>To modify your <code>\/etc\/hosts<\/code> file if your workstation runs macOS or a Linux distribution, perform the following steps:<\/p>\n<ol>\n<li>On your workstation, open the <code>\/etc\/hosts<\/code> file with your preferred text editor.<\/li>\n<li>Add the server\u2019s IP address and domain name under the last entry in the file, for example:\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#ae81ff\">127<\/span>.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n::1 localhost localhost.localdomain localhost6 localhost6.localdomain6\n<span style=\"color:#ae81ff\">192<\/span>.168.0.20    example.com\n<span style=\"color:#ae81ff\">1<\/span>.2.3.4 username.example.com<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>In this example, <code>1.2.3.4<\/code> represents the server\u2019s IP address, and <code>username.example.com<\/code> represents the domain name.<\/p>\n<\/p><\/div>\n<\/div>\n<\/li>\n<li>Save your changes.<\/li>\n<li>Reload your browser for the changes to take effect.<\/li>\n<\/ol>\n<h3 id=\"microsoft-windows\">Microsoft Windows\u00ae<\/h3>\n<p>To modify the <code>\/etc\/hosts<\/code> file on a Windows workstation, perform the following steps:<\/p>\n<ol>\n<li>Open the <em>Start<\/em> menu.\n<ul>\n<li>If you run Windows 8 or Windows 10, type <strong>Win+X<\/strong> on the keyboard or click the Windows icon in the lower-left corner of your desktop interface.<\/li>\n<li>If you run Windows 7 or Windows Vista\u00ae, click <em>Start<\/em>.<\/li>\n<\/ul>\n<\/li>\n<li>Enter Notepad in the search text box.<\/li>\n<li>Right-click <em>Notepad<\/em> and select <em>Run as Administrator<\/em>.<\/li>\n<li>In <em>Notepad<\/em>, open the following file:\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">C:<span style=\"color:#ae81ff\">W<\/span>indows<span style=\"color:#ae81ff\">S<\/span>ystem32<span style=\"color:#ae81ff\">D<\/span>rivers<span style=\"color:#ae81ff\">e<\/span>tc<span style=\"color:#ae81ff\">h<\/span>osts<\/code><\/pre>\n<\/div>\n<\/li>\n<li>Add the destination server\u2019s IP address and domain name under the latest entry in the file, for example:\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"color:#ae81ff\">127<\/span>.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n::1 localhost localhost.localdomain localhost6 localhost6.localdomain6\n<span style=\"color:#ae81ff\">192<\/span>.168.0.20 example.com\n<span style=\"color:#ae81ff\">1<\/span>.2.3.4 username.example.com<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>In this example, <code>1.2.3.4<\/code> represents the destination server\u2019s IP address, and <code>username.example.com<\/code> represents the domain name.<\/p>\n<\/p><\/div>\n<\/div>\n<\/li>\n<li>Save your changes.<\/li>\n<li>Reload your browser for the changes to take effect.<\/li>\n<\/ol><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview Your hosting provider may offer you a temporary URL in the http:\/\/IP\/~username format (where IP represents the server\u2019s IP address and username represents the cPanel account name) to access your website. This is useful, for example, if you migrate your website to a new server and want to test the site before you point &hellip;<\/p>\n","protected":false},"author":1,"featured_media":378,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/377"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/378"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}