Search code examples
phpaliaseasyphp

EasyPHP - localhost alias


I'm using the latest version of EasyPHP on Windows 10 and I would like to achieve one thing which I cannot find an answer to.

I achieve my projects for example like localhost/myproject. Everything is working but it's kind of annoying because my browser's (Google Chrome) autocomplete is kind of useless when all my projects start with localhost

I would like to achieve (probably through Apache config) the thing that when I type for example myproject.dev in my browser it shows me project localhost/myproject. Redirect would be enough but if it worked on the domain the whole time like it does on regular server that would be perfect. So basically I need something like ngrok but with custom domains and it does not need to be public.

It does not need to be automatic, I'm OK with setting each domain manually.


Solution

  • This can be easily achieved.

    First add a new line inside hosts file, located at C:\Windows\System32\drivers\etc:

    127.0.0.1       myproject.dev
    

    Then locate httpd-vhosts.conf or httpd.conf and near the end add:

    <VirtualHost myproject.dev>
        DocumentRoot "path/to/folder/myproject"
        ServerName myproject.dev
        ServerAlias myproject.dev
        <Directory "path/to/folder/myproject">
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>