folder - Make an IP forward to a directory on local machine

08
2014-07
  • Neurolocopter

    I would like to setup a forward, where I open my web browser, type in an address such as: http://helpdocs and it direct me to a folder on my computer with a HTML file in it, such as in a website. I thought about editing the hosts file, but I'm not sure what to modify. I can use a local Webserver, however I thought of trying this first.

    Is this possible?

    Thanks.

    EDIT:

    Hosts file edited:

    127.0.0.1 1.web.docs 1.web.webs #WEBSITES
    

    and configuration edited:

    <Directory C:/1web>
    Order Deny,Allow   
    Allow from all 
    </Directory>
    <VirtualHost *:80>
    DocumentRoot C:/1web/helpdocs/
    ServerName 1.web.docs
    </VirtualHost>
    <VirtualHost *:80>
    DocumentRoot C:/1web/webs/
    ServerName 1.web.webs
    </VirtualHost>
    

    Is it possible that the lines already in the WAMP hosts config are conflicting with it?

  • Answers
  • Bandrami

    Sure, you can do that; just set up a web server like apache or PWS or something, set its default website's root folder to your help directory, and go to

    http://localhost
    

    But why not just do

    file://C:/Somewhere/some_file.htm
    

    and bookmark that?

    Per your comment below, set up in your hosts file

    127.0.0.1  localhost  helpdocs  webtest
    

    And set up in Apache or PWS or whatever multiple sites that listen for those host headers.

    Per your next comment, here's what an httpd.conf might look like (after you've done the hosts edit above):

    <VirtualHost *:80>
     DocumentRoot C:/htdocs/help/
     ServerName helpdocs
    </VirtualHost>
    <VirtualHost *:80>
     DocumentRoot C:/htdocs/web/
     ServerName webtest
    </VirtualHost>
    

    (Adjust the DocumentRoot lines as appropriate...)


  • Related Question

    Load local file in place of remote file (HTTP) address in Windows
  • ev.

    I am trying to achieve something that you might typically use a hosts file for, but that isn't suitable here.

    I want a Windows PC to refer to a local file (I can serve it from a web server at localhost if needed) when it attempts to fetch a certain remote file via HTTP. However, I need other files from that particular remote web server to be fetched as usual.

    Any help appreciated.

    Edit:

    The specific case is that I'm customising a web application which I don't own and can't run locally. It is a hosted web app, and custom css is added through a standard html text field, which is immediately applied to your production site. This of course limits my testing options.

    So, I have been testing by applying a user-specified css file from my local machine. This works great in browsers that allow it.

    I want to test old browsers that don't allow user-specified css, so I want to intercept all outbound requests to the remote css file and redirect them to a local css file (which I can refer to using file://, http://, whatever - I will do what I have to do. If the recommended method requires the local file to be served using http, I don't mind firing up a quick instance of Python's SimpleHTTPServer on a local port).

    I can't redirect the entire hostname, because then the third-party site won't load at all. I just want to intercept requests to one particular URL and instead point at my local file.


    I should also note that the remote web app does not allow the use of css import statements, because that is the obvious solution to this problem.


  • Related Answers
  • grawity

    Many HTTP proxy servers (such as Squid or Privoxy) are able to redirect requests.


    Squid:


    Privoxy:

    { +redirect{http://localhost/example.com.css} }
    example.com/stylesheet\.css$
    
  • Ignacio Vazquez-Abrams

    If by "web server" you mean "httpd" then mod_proxy's ProxyPass is what you're looking for.