Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many solutions for your problem, but I'm gonna try to focus on the most mature one. I assume you are using windows as your environment.</p> <p>You said you were running your projects on localhost, which is where your first mistake is.</p> <p>Localhost is nothing but a form of weird domain name you specify. When you request a domain like "www.google.com" or "localhost" the following steps occur:</p> <ol> <li>The browser checks a specific file for the requested domain. This file is called <a href="https://en.wikipedia.org/wiki/Hosts_%28file%29" rel="nofollow">hosts file</a></li> <li>If the domain name is found in the hosts file, the browser sends a request to the IP address specified in the hosts file</li> <li>If the domain name is not found in the hosts file, the browser queries domain name servers which return the corresponding IP adress.</li> </ol> <p>Now localhost is nothing but a domain name specified in your hosts file, which points to the loopback address.(127.0.0.1).</p> <p>So the magic trick here is to bind your custom hosts like "project1", "project2" etc.. to that loopback adress(127.0.0.1).</p> <p>Than when you send a request to "project1" in your browser, the server running on port 80 will respond as if you typed "localhost".</p> <p>The second part you need to take care of is called <a href="http://httpd.apache.org/docs/2.2/vhosts/" rel="nofollow">virtual hosts</a>. When you send a request with a specific domain name, a special header is included in your http request called "Host". </p> <p>Lets assume, that you redirect all this custom domains to the same IP (127.0.0.1). In order for apache to serve a different project, you should instruct apache to look at the "Host" header and resolve it for the corresponding project.</p> <p>Again you do that by setting <a href="http://httpd.apache.org/docs/2.2/vhosts/examples.html" rel="nofollow">virtual hosts</a>.</p> <p>A lot of frameworks and content managing systems in PHP have some ugly ways to insert some magic "$BASE_PATH" variable, which is a bad practice as that could be achieved with relative paths in pure html and a properly configured server.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload