Skip to content

Instantly share code, notes, and snippets.

@alphaolomi
Last active March 25, 2020 14:32
Show Gist options
  • Save alphaolomi/6b4a3ed57a4b6d8a9ca08c15edbe6500 to your computer and use it in GitHub Desktop.
Save alphaolomi/6b4a3ed57a4b6d8a9ca08c15edbe6500 to your computer and use it in GitHub Desktop.
Custom localhost Url

Custom Localhost URL

For Windows

Assuming using XAMPP Server

  1. Open [C:\Windows\System32\Drivers\etc\hosts](file://C:\Windows\System32\Drivers\etc\hosts)
127.0.0.1     something.local
  1. Go to [your_XAMPP_directory]\apache\conf\httpd.conf by ussualy its located in [C:\xampp\apache\conf\httpd.conf](file://C:\xampp\apache\conf\httpd.conf) and at the bottom of the file:
<VirtualHost *:80>
    DocumentRoot "[PATH_TO_YOUR_CUSTOM_FOLDER]"
    ServerName something.local

    <Directory "[PATH_TO_YOUR_CUSTOM_FOLDER]">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>
  • Replace PATH_TO_YOUR_CUSTOM_FOLDER to the folder where your files are located. Ex: C:/xampp/htdocs/.

  • something.local must be the same on Step 1 & Step 3.

  1. Open the XAMPP Control Panel

  2. Stop Apache , wait for 5 seconds,

  3. then finally "Start" Apache Server.

For Linux(Ubuntu),

Assuming using LAMPP

  1. Go to /etc/hosts and add this to the bottom of the file:
127.0.0.1     something.local
  1. Go to /opt/apache/conf/httpd.conf at the bottom of the file:
<VirtualHost *:80>
   DocumentRoot "PATH_TO_YOUR_CUSTOM_FOLDER"
   ServerName something.local

   <Directory "PATH_TO_YOUR_CUSTOM_FOLDER">
     Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Require all granted
    </Directory>

</VirtualHost>
  • Replace PATH_TO_YOUR_CUSTOM_FOLDER to the folder where your files are located. Ex: /opt/lampp/htdocs/.
  • something.local must be the same on Step 1 & Step 3.
  1. Restart Apache Server
sudo /opt/lampp/apache stop
sudo opt/lampp/spache start

Assuming all went well, go to your browser, type http://something.local and it will now happily point to your custom local folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment