Simulate manipulation of the etc/hosts file in Google Chrome












27















How can I set up Chrome to reference hostname lookups locally and not from the standard
etc/hosts file?



When debugging a website, it's sometimes useful to set up entries in C:Windowssystem32driversetchosts that replace certain domains with localhost, thus allowing me to test out on-the-fly versions of websites or domains that may conflict with live actual sites.



Can I set up Google Chrome in a way that simulates and simplifies this process?



I won't to modify the browser instance to behave as if etc/hosts has been modified although even that might be too much of a security risk in an extension.










share|improve this question

























  • Please star this feature request: bugs.chromium.org/p/chromium/issues/…

    – Ali
    Oct 8 '18 at 15:31
















27















How can I set up Chrome to reference hostname lookups locally and not from the standard
etc/hosts file?



When debugging a website, it's sometimes useful to set up entries in C:Windowssystem32driversetchosts that replace certain domains with localhost, thus allowing me to test out on-the-fly versions of websites or domains that may conflict with live actual sites.



Can I set up Google Chrome in a way that simulates and simplifies this process?



I won't to modify the browser instance to behave as if etc/hosts has been modified although even that might be too much of a security risk in an extension.










share|improve this question

























  • Please star this feature request: bugs.chromium.org/p/chromium/issues/…

    – Ali
    Oct 8 '18 at 15:31














27












27








27


9






How can I set up Chrome to reference hostname lookups locally and not from the standard
etc/hosts file?



When debugging a website, it's sometimes useful to set up entries in C:Windowssystem32driversetchosts that replace certain domains with localhost, thus allowing me to test out on-the-fly versions of websites or domains that may conflict with live actual sites.



Can I set up Google Chrome in a way that simulates and simplifies this process?



I won't to modify the browser instance to behave as if etc/hosts has been modified although even that might be too much of a security risk in an extension.










share|improve this question
















How can I set up Chrome to reference hostname lookups locally and not from the standard
etc/hosts file?



When debugging a website, it's sometimes useful to set up entries in C:Windowssystem32driversetchosts that replace certain domains with localhost, thus allowing me to test out on-the-fly versions of websites or domains that may conflict with live actual sites.



Can I set up Google Chrome in a way that simulates and simplifies this process?



I won't to modify the browser instance to behave as if etc/hosts has been modified although even that might be too much of a security risk in an extension.







google-chrome google-chrome-extensions hosts-file






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '13 at 1:25









random

12.8k84757




12.8k84757










asked Oct 5 '11 at 9:41









ripper234ripper234

4,3633073105




4,3633073105













  • Please star this feature request: bugs.chromium.org/p/chromium/issues/…

    – Ali
    Oct 8 '18 at 15:31



















  • Please star this feature request: bugs.chromium.org/p/chromium/issues/…

    – Ali
    Oct 8 '18 at 15:31

















Please star this feature request: bugs.chromium.org/p/chromium/issues/…

– Ali
Oct 8 '18 at 15:31





Please star this feature request: bugs.chromium.org/p/chromium/issues/…

– Ali
Oct 8 '18 at 15:31










6 Answers
6






active

oldest

votes


















10














I just found the Host Switch Plus Chrome Extension which does exactly that ;)






share|improve this answer
























  • Host Switch Plus doesn't work for me and many others.

    – zylstra
    Mar 18 '17 at 2:23






  • 1





    Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

    – TEXHIK
    Jun 6 '17 at 16:43













  • Does not work for me, sorry.

    – Serzhan Akhmetov
    Aug 8 '18 at 6:31



















6














One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.



There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.



For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.



Note that this is far better than what you are doing with the hosts file, which is an unsuitable mechanism for manipulating WWW service. hosts only deals in name→address lookups, mucks up everything else (outwith the WWW browser) that needs to do name→address lookups, and (as you probably know already) requires every rewritten host name to be additionally set up as a virtual host on the target content HTTP server. A rewriting proxy HTTP server of this sort, in contrast, deals in URLs and only affects HTTP and the WWW browsers configured to use it in the first place. So it can do things like only rewrite the JavaScript URLs and leave everything else from the same WWW site alone; rewrite a whole load of hostnames to just one; and do (yet further) pattern matching. (There are instances of this very thing in Ad Zapper's configuration database, notice.) And one can do things like have one WWW browser viewing the world through the rewriting proxy and another viewing it directly, on a single machine simultaneously.






share|improve this answer
























  • One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

    – ripper234
    Oct 6 '11 at 13:26



















2














Maybe this saves you some steps in editing the .hosts file: http://www.howtogeek.com/howto/6540/stupid-geek-tricks-create-a-shortcut-to-quickly-edit-your-hosts-file/




right-click the start menu and create a shortcut, with the following
location:



notepad c:windowssystem32driversetchosts


open up the shortcut properties, click the Advanced button, and then
select the "Run as administrator" option.



Once you’ve done so, you can simply type hosts into the start menu and start editing







share|improve this answer


























  • This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

    – Michael Mrozek
    Dec 10 '18 at 19:15











  • @MichaelMrozek His final task is to simplify the process.

    – mgutt
    Dec 11 '18 at 12:10



















2














I used (and still use) HostAdmin religiously, but having to empty the cache or opening a new incognito window every time has always been a chore, so I ended up developing a Chrome extension for myself last year to help with a similar situation, and I recently published a very rough version of it in the Chrome Web Store, it's called LiveHosts.



The gist of it is that while @JdeBP is right and setting up a proxy would be the correct solution, it's often not an option. A Chrome extension cannot exactly replicate what happens when you change the hostfile though, so what LiveHosts does right now is:




  • lets you set up multiple hostname/IP entries;

  • detect requests to one of the defined hostnames;

  • redirect the request to the desired IP with the appropriate HTTP Host header;

  • add a visual (and ugly, I'll admit) reference in the address bar URL, which will look something like http://127.0.0.1/www.example.com/whateverelse;

  • allow different host/IP pairings in different tabs at the same time.


It's not pretty, but it's good enough for the standard web developer who's trying to switch between environments quick. There are of course a few caveats:




  • depending on the server, parts of a web page referring to the site URL (like href and src attributes) could be different from the original;


  • window.location has a different value that can potentially throw off JavaScript snippets;

  • most Cross-Origin request won't work.






share|improve this answer

































    0














    The Virtual Hosts plugin is the only one that has work for me as I expected.




    Access virtual hosts of a server without the need of host redirection or DNS.







    share|improve this answer



















    • 1





      For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

      – Jeff Ward
      Feb 6 '18 at 16:31



















    -1














    Try the extension DNS Overrider:



    Using DNS Overrider you can replace hostname on the fly without access to 
    system settings such as hosts file. DNS Overrider enables you to select what
    rules to apply via the extension settings page.


    https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh/






    share|improve this answer



















    • 4





      This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

      – Peter Olson
      Jan 19 '15 at 3:08











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f343158%2fsimulate-manipulation-of-the-etc-hosts-file-in-google-chrome%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    6 Answers
    6






    active

    oldest

    votes








    6 Answers
    6






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    I just found the Host Switch Plus Chrome Extension which does exactly that ;)






    share|improve this answer
























    • Host Switch Plus doesn't work for me and many others.

      – zylstra
      Mar 18 '17 at 2:23






    • 1





      Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

      – TEXHIK
      Jun 6 '17 at 16:43













    • Does not work for me, sorry.

      – Serzhan Akhmetov
      Aug 8 '18 at 6:31
















    10














    I just found the Host Switch Plus Chrome Extension which does exactly that ;)






    share|improve this answer
























    • Host Switch Plus doesn't work for me and many others.

      – zylstra
      Mar 18 '17 at 2:23






    • 1





      Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

      – TEXHIK
      Jun 6 '17 at 16:43













    • Does not work for me, sorry.

      – Serzhan Akhmetov
      Aug 8 '18 at 6:31














    10












    10








    10







    I just found the Host Switch Plus Chrome Extension which does exactly that ;)






    share|improve this answer













    I just found the Host Switch Plus Chrome Extension which does exactly that ;)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 7 '16 at 20:02









    mettjusmettjus

    20124




    20124













    • Host Switch Plus doesn't work for me and many others.

      – zylstra
      Mar 18 '17 at 2:23






    • 1





      Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

      – TEXHIK
      Jun 6 '17 at 16:43













    • Does not work for me, sorry.

      – Serzhan Akhmetov
      Aug 8 '18 at 6:31



















    • Host Switch Plus doesn't work for me and many others.

      – zylstra
      Mar 18 '17 at 2:23






    • 1





      Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

      – TEXHIK
      Jun 6 '17 at 16:43













    • Does not work for me, sorry.

      – Serzhan Akhmetov
      Aug 8 '18 at 6:31

















    Host Switch Plus doesn't work for me and many others.

    – zylstra
    Mar 18 '17 at 2:23





    Host Switch Plus doesn't work for me and many others.

    – zylstra
    Mar 18 '17 at 2:23




    1




    1





    Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

    – TEXHIK
    Jun 6 '17 at 16:43







    Host Switch Plus doing exactly NOT that. It changes proxy. But the target is to change domain IP. (Emulate DNS-server)

    – TEXHIK
    Jun 6 '17 at 16:43















    Does not work for me, sorry.

    – Serzhan Akhmetov
    Aug 8 '18 at 6:31





    Does not work for me, sorry.

    – Serzhan Akhmetov
    Aug 8 '18 at 6:31













    6














    One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.



    There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.



    For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.



    Note that this is far better than what you are doing with the hosts file, which is an unsuitable mechanism for manipulating WWW service. hosts only deals in name→address lookups, mucks up everything else (outwith the WWW browser) that needs to do name→address lookups, and (as you probably know already) requires every rewritten host name to be additionally set up as a virtual host on the target content HTTP server. A rewriting proxy HTTP server of this sort, in contrast, deals in URLs and only affects HTTP and the WWW browsers configured to use it in the first place. So it can do things like only rewrite the JavaScript URLs and leave everything else from the same WWW site alone; rewrite a whole load of hostnames to just one; and do (yet further) pattern matching. (There are instances of this very thing in Ad Zapper's configuration database, notice.) And one can do things like have one WWW browser viewing the world through the rewriting proxy and another viewing it directly, on a single machine simultaneously.






    share|improve this answer
























    • One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

      – ripper234
      Oct 6 '11 at 13:26
















    6














    One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.



    There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.



    For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.



    Note that this is far better than what you are doing with the hosts file, which is an unsuitable mechanism for manipulating WWW service. hosts only deals in name→address lookups, mucks up everything else (outwith the WWW browser) that needs to do name→address lookups, and (as you probably know already) requires every rewritten host name to be additionally set up as a virtual host on the target content HTTP server. A rewriting proxy HTTP server of this sort, in contrast, deals in URLs and only affects HTTP and the WWW browsers configured to use it in the first place. So it can do things like only rewrite the JavaScript URLs and leave everything else from the same WWW site alone; rewrite a whole load of hostnames to just one; and do (yet further) pattern matching. (There are instances of this very thing in Ad Zapper's configuration database, notice.) And one can do things like have one WWW browser viewing the world through the rewriting proxy and another viewing it directly, on a single machine simultaneously.






    share|improve this answer
























    • One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

      – ripper234
      Oct 6 '11 at 13:26














    6












    6








    6







    One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.



    There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.



    For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.



    Note that this is far better than what you are doing with the hosts file, which is an unsuitable mechanism for manipulating WWW service. hosts only deals in name→address lookups, mucks up everything else (outwith the WWW browser) that needs to do name→address lookups, and (as you probably know already) requires every rewritten host name to be additionally set up as a virtual host on the target content HTTP server. A rewriting proxy HTTP server of this sort, in contrast, deals in URLs and only affects HTTP and the WWW browsers configured to use it in the first place. So it can do things like only rewrite the JavaScript URLs and leave everything else from the same WWW site alone; rewrite a whole load of hostnames to just one; and do (yet further) pattern matching. (There are instances of this very thing in Ad Zapper's configuration database, notice.) And one can do things like have one WWW browser viewing the world through the rewriting proxy and another viewing it directly, on a single machine simultaneously.






    share|improve this answer













    One way to achieve your actual goal does not involve Chrome extensions, or even Chrome, at all. That way is to set up an intelligent proxy HTTP server, point Chrome at it, and then add rewriting rules to the proxy server that rewrite URLs under the covers.



    There are many people who do this, with various different proxy HTTP servers — too many to cover each in detail in an answer here. They do so for purposes of zapping advertisements, web bugs, and suchlike, but the principle and the mechanism are identical to what you want to do. They want the WWW browser to fetch a particular URL as normal, but the actual content that it receives to be that of some other (local or otherwise) URL. The only thing that the WWW browser needs to know is that it talks to Internet via a proxy server.



    For one example, see the Ad Zapper at SourceForge. That's a Perl script that works in conjunction with the Squid proxy HTTP server to rewrite URLs on the fly in the proxy server. As you can see from its configuration database, people have employed its mechanism for a wide range of purposes, from ensuring that one always sees the "printable" forms of articles on news services to getting rid of the randomized advertising redirections on Internet pornography sites.



    Note that this is far better than what you are doing with the hosts file, which is an unsuitable mechanism for manipulating WWW service. hosts only deals in name→address lookups, mucks up everything else (outwith the WWW browser) that needs to do name→address lookups, and (as you probably know already) requires every rewritten host name to be additionally set up as a virtual host on the target content HTTP server. A rewriting proxy HTTP server of this sort, in contrast, deals in URLs and only affects HTTP and the WWW browsers configured to use it in the first place. So it can do things like only rewrite the JavaScript URLs and leave everything else from the same WWW site alone; rewrite a whole load of hostnames to just one; and do (yet further) pattern matching. (There are instances of this very thing in Ad Zapper's configuration database, notice.) And one can do things like have one WWW browser viewing the world through the rewriting proxy and another viewing it directly, on a single machine simultaneously.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 6 '11 at 13:20









    JdeBPJdeBP

    22.5k14890




    22.5k14890













    • One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

      – ripper234
      Oct 6 '11 at 13:26



















    • One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

      – ripper234
      Oct 6 '11 at 13:26

















    One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

    – ripper234
    Oct 6 '11 at 13:26





    One additional benefit over a chrome extension - it works cross browsers! Right now I'm still using the hosts file, but I'll consider switching to a proxy if the actual need arises.

    – ripper234
    Oct 6 '11 at 13:26











    2














    Maybe this saves you some steps in editing the .hosts file: http://www.howtogeek.com/howto/6540/stupid-geek-tricks-create-a-shortcut-to-quickly-edit-your-hosts-file/




    right-click the start menu and create a shortcut, with the following
    location:



    notepad c:windowssystem32driversetchosts


    open up the shortcut properties, click the Advanced button, and then
    select the "Run as administrator" option.



    Once you’ve done so, you can simply type hosts into the start menu and start editing







    share|improve this answer


























    • This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

      – Michael Mrozek
      Dec 10 '18 at 19:15











    • @MichaelMrozek His final task is to simplify the process.

      – mgutt
      Dec 11 '18 at 12:10
















    2














    Maybe this saves you some steps in editing the .hosts file: http://www.howtogeek.com/howto/6540/stupid-geek-tricks-create-a-shortcut-to-quickly-edit-your-hosts-file/




    right-click the start menu and create a shortcut, with the following
    location:



    notepad c:windowssystem32driversetchosts


    open up the shortcut properties, click the Advanced button, and then
    select the "Run as administrator" option.



    Once you’ve done so, you can simply type hosts into the start menu and start editing







    share|improve this answer


























    • This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

      – Michael Mrozek
      Dec 10 '18 at 19:15











    • @MichaelMrozek His final task is to simplify the process.

      – mgutt
      Dec 11 '18 at 12:10














    2












    2








    2







    Maybe this saves you some steps in editing the .hosts file: http://www.howtogeek.com/howto/6540/stupid-geek-tricks-create-a-shortcut-to-quickly-edit-your-hosts-file/




    right-click the start menu and create a shortcut, with the following
    location:



    notepad c:windowssystem32driversetchosts


    open up the shortcut properties, click the Advanced button, and then
    select the "Run as administrator" option.



    Once you’ve done so, you can simply type hosts into the start menu and start editing







    share|improve this answer















    Maybe this saves you some steps in editing the .hosts file: http://www.howtogeek.com/howto/6540/stupid-geek-tricks-create-a-shortcut-to-quickly-edit-your-hosts-file/




    right-click the start menu and create a shortcut, with the following
    location:



    notepad c:windowssystem32driversetchosts


    open up the shortcut properties, click the Advanced button, and then
    select the "Run as administrator" option.



    Once you’ve done so, you can simply type hosts into the start menu and start editing








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 25 '15 at 21:28









    bwDraco

    36.7k36135177




    36.7k36135177










    answered Jan 24 '15 at 17:27









    mguttmgutt

    306317




    306317













    • This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

      – Michael Mrozek
      Dec 10 '18 at 19:15











    • @MichaelMrozek His final task is to simplify the process.

      – mgutt
      Dec 11 '18 at 12:10



















    • This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

      – Michael Mrozek
      Dec 10 '18 at 19:15











    • @MichaelMrozek His final task is to simplify the process.

      – mgutt
      Dec 11 '18 at 12:10

















    This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

    – Michael Mrozek
    Dec 10 '18 at 19:15





    This doesn't answer the question at all, the question is about how to avoid modifying hosts at all

    – Michael Mrozek
    Dec 10 '18 at 19:15













    @MichaelMrozek His final task is to simplify the process.

    – mgutt
    Dec 11 '18 at 12:10





    @MichaelMrozek His final task is to simplify the process.

    – mgutt
    Dec 11 '18 at 12:10











    2














    I used (and still use) HostAdmin religiously, but having to empty the cache or opening a new incognito window every time has always been a chore, so I ended up developing a Chrome extension for myself last year to help with a similar situation, and I recently published a very rough version of it in the Chrome Web Store, it's called LiveHosts.



    The gist of it is that while @JdeBP is right and setting up a proxy would be the correct solution, it's often not an option. A Chrome extension cannot exactly replicate what happens when you change the hostfile though, so what LiveHosts does right now is:




    • lets you set up multiple hostname/IP entries;

    • detect requests to one of the defined hostnames;

    • redirect the request to the desired IP with the appropriate HTTP Host header;

    • add a visual (and ugly, I'll admit) reference in the address bar URL, which will look something like http://127.0.0.1/www.example.com/whateverelse;

    • allow different host/IP pairings in different tabs at the same time.


    It's not pretty, but it's good enough for the standard web developer who's trying to switch between environments quick. There are of course a few caveats:




    • depending on the server, parts of a web page referring to the site URL (like href and src attributes) could be different from the original;


    • window.location has a different value that can potentially throw off JavaScript snippets;

    • most Cross-Origin request won't work.






    share|improve this answer






























      2














      I used (and still use) HostAdmin religiously, but having to empty the cache or opening a new incognito window every time has always been a chore, so I ended up developing a Chrome extension for myself last year to help with a similar situation, and I recently published a very rough version of it in the Chrome Web Store, it's called LiveHosts.



      The gist of it is that while @JdeBP is right and setting up a proxy would be the correct solution, it's often not an option. A Chrome extension cannot exactly replicate what happens when you change the hostfile though, so what LiveHosts does right now is:




      • lets you set up multiple hostname/IP entries;

      • detect requests to one of the defined hostnames;

      • redirect the request to the desired IP with the appropriate HTTP Host header;

      • add a visual (and ugly, I'll admit) reference in the address bar URL, which will look something like http://127.0.0.1/www.example.com/whateverelse;

      • allow different host/IP pairings in different tabs at the same time.


      It's not pretty, but it's good enough for the standard web developer who's trying to switch between environments quick. There are of course a few caveats:




      • depending on the server, parts of a web page referring to the site URL (like href and src attributes) could be different from the original;


      • window.location has a different value that can potentially throw off JavaScript snippets;

      • most Cross-Origin request won't work.






      share|improve this answer




























        2












        2








        2







        I used (and still use) HostAdmin religiously, but having to empty the cache or opening a new incognito window every time has always been a chore, so I ended up developing a Chrome extension for myself last year to help with a similar situation, and I recently published a very rough version of it in the Chrome Web Store, it's called LiveHosts.



        The gist of it is that while @JdeBP is right and setting up a proxy would be the correct solution, it's often not an option. A Chrome extension cannot exactly replicate what happens when you change the hostfile though, so what LiveHosts does right now is:




        • lets you set up multiple hostname/IP entries;

        • detect requests to one of the defined hostnames;

        • redirect the request to the desired IP with the appropriate HTTP Host header;

        • add a visual (and ugly, I'll admit) reference in the address bar URL, which will look something like http://127.0.0.1/www.example.com/whateverelse;

        • allow different host/IP pairings in different tabs at the same time.


        It's not pretty, but it's good enough for the standard web developer who's trying to switch between environments quick. There are of course a few caveats:




        • depending on the server, parts of a web page referring to the site URL (like href and src attributes) could be different from the original;


        • window.location has a different value that can potentially throw off JavaScript snippets;

        • most Cross-Origin request won't work.






        share|improve this answer















        I used (and still use) HostAdmin religiously, but having to empty the cache or opening a new incognito window every time has always been a chore, so I ended up developing a Chrome extension for myself last year to help with a similar situation, and I recently published a very rough version of it in the Chrome Web Store, it's called LiveHosts.



        The gist of it is that while @JdeBP is right and setting up a proxy would be the correct solution, it's often not an option. A Chrome extension cannot exactly replicate what happens when you change the hostfile though, so what LiveHosts does right now is:




        • lets you set up multiple hostname/IP entries;

        • detect requests to one of the defined hostnames;

        • redirect the request to the desired IP with the appropriate HTTP Host header;

        • add a visual (and ugly, I'll admit) reference in the address bar URL, which will look something like http://127.0.0.1/www.example.com/whateverelse;

        • allow different host/IP pairings in different tabs at the same time.


        It's not pretty, but it's good enough for the standard web developer who's trying to switch between environments quick. There are of course a few caveats:




        • depending on the server, parts of a web page referring to the site URL (like href and src attributes) could be different from the original;


        • window.location has a different value that can potentially throw off JavaScript snippets;

        • most Cross-Origin request won't work.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 8 at 19:38

























        answered Mar 23 '18 at 1:32









        AiorosAioros

        1214




        1214























            0














            The Virtual Hosts plugin is the only one that has work for me as I expected.




            Access virtual hosts of a server without the need of host redirection or DNS.







            share|improve this answer



















            • 1





              For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

              – Jeff Ward
              Feb 6 '18 at 16:31
















            0














            The Virtual Hosts plugin is the only one that has work for me as I expected.




            Access virtual hosts of a server without the need of host redirection or DNS.







            share|improve this answer



















            • 1





              For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

              – Jeff Ward
              Feb 6 '18 at 16:31














            0












            0








            0







            The Virtual Hosts plugin is the only one that has work for me as I expected.




            Access virtual hosts of a server without the need of host redirection or DNS.







            share|improve this answer













            The Virtual Hosts plugin is the only one that has work for me as I expected.




            Access virtual hosts of a server without the need of host redirection or DNS.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 21 '16 at 14:51









            JDLJDL

            1091




            1091








            • 1





              For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

              – Jeff Ward
              Feb 6 '18 at 16:31














            • 1





              For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

              – Jeff Ward
              Feb 6 '18 at 16:31








            1




            1





            For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

            – Jeff Ward
            Feb 6 '18 at 16:31





            For me, this extension seems to do a client-side redirect to the IP address, which is not at all the same as a hosts file modification.

            – Jeff Ward
            Feb 6 '18 at 16:31











            -1














            Try the extension DNS Overrider:



            Using DNS Overrider you can replace hostname on the fly without access to 
            system settings such as hosts file. DNS Overrider enables you to select what
            rules to apply via the extension settings page.


            https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh/






            share|improve this answer



















            • 4





              This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

              – Peter Olson
              Jan 19 '15 at 3:08
















            -1














            Try the extension DNS Overrider:



            Using DNS Overrider you can replace hostname on the fly without access to 
            system settings such as hosts file. DNS Overrider enables you to select what
            rules to apply via the extension settings page.


            https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh/






            share|improve this answer



















            • 4





              This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

              – Peter Olson
              Jan 19 '15 at 3:08














            -1












            -1








            -1







            Try the extension DNS Overrider:



            Using DNS Overrider you can replace hostname on the fly without access to 
            system settings such as hosts file. DNS Overrider enables you to select what
            rules to apply via the extension settings page.


            https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh/






            share|improve this answer













            Try the extension DNS Overrider:



            Using DNS Overrider you can replace hostname on the fly without access to 
            system settings such as hosts file. DNS Overrider enables you to select what
            rules to apply via the extension settings page.


            https://chrome.google.com/webstore/detail/dns-overrider/acmhaiiijfheggcaanjlgpampclpbnoh/







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 28 '13 at 12:00









            RavanHRavanH

            1072




            1072








            • 4





              This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

              – Peter Olson
              Jan 19 '15 at 3:08














            • 4





              This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

              – Peter Olson
              Jan 19 '15 at 3:08








            4




            4





            This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

            – Peter Olson
            Jan 19 '15 at 3:08





            This doesn't do anything with DNS resolution, it just changes URLs in the page DOM

            – Peter Olson
            Jan 19 '15 at 3:08


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f343158%2fsimulate-manipulation-of-the-etc-hosts-file-in-google-chrome%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido