> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.bearsampp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Up a Custom Local Domain with Bearsampp

> Create a virtual host in Bearsampp to access your local project at a custom domain like myproject.local instead of a subfolder under localhost.

By default, you access your projects under `http://localhost/yourproject`. A virtual host lets you assign a custom local domain — like `myproject.local` — so each project gets its own URL and its own document root. Bearsampp creates the Apache configuration for you; you just need to add one line to your Windows hosts file.

## Create the virtual host

<Steps>
  <Step title="Open the Add virtual host dialog">
    Right-click the Bearsampp tray icon, hover over **Apache**, and click **Add a virtual host**.
  </Step>

  <Step title="Enter a server name">
    In the **Server name** field, type your local domain. Use a valid domain format such as `myproject.local`. Bearsampp validates the input and will not save a plain alphanumeric name without dots.
  </Step>

  <Step title="Set the document root">
    Click **Browse** next to the **Document root** field and select the folder that contains your project files.
  </Step>

  <Step title="Save the virtual host">
    Click **Save**. Bearsampp:

    * Creates an Apache virtual host config file for your domain
    * Generates an SSL certificate for `myproject.local` automatically
    * Restarts Apache to apply the changes

    A confirmation dialog tells you the virtual host was created and reminds you to add the domain to your hosts file.
  </Step>
</Steps>

## Add the domain to your hosts file

Windows does not know about `myproject.local` yet. You need to tell it to resolve the domain to your local machine by editing the system hosts file.

<Steps>
  <Step title="Open Notepad as Administrator">
    Press the **Windows** key, type `Notepad`, right-click it in the search results, and select **Run as administrator**.
  </Step>

  <Step title="Open the hosts file">
    In Notepad, go to **File → Open** and navigate to:

    ```
    C:\Windows\System32\drivers\etc\hosts
    ```

    Make sure the file type filter is set to **All Files** so the `hosts` file (which has no extension) is visible.
  </Step>

  <Step title="Add your domain entry">
    Scroll to the bottom of the file and add a new line:

    ```text theme={null}
    127.0.0.1  myproject.local
    ```
  </Step>

  <Step title="Save the file">
    Save the file in Notepad. Because you opened Notepad as Administrator, you can save directly to `System32\drivers\etc\`.
  </Step>

  <Step title="Open your local domain in a browser">
    Navigate to `http://myproject.local` or `https://myproject.local`. Your project should load immediately.
  </Step>
</Steps>

<Tip>
  Bearsampp includes a built-in **HostsEditor** tool that provides a simpler interface for editing the hosts file. Access it from the tray icon under **Tools → HostsEditor**. It handles the Administrator permissions automatically.
</Tip>

<Note>
  After editing the hosts file, your browser may still resolve the old address for a short time due to DNS caching. To clear it immediately, open a Command Prompt and run:

  ```bash theme={null}
  ipconfig /flushdns
  ```
</Note>

<Warning>
  The server name must be a valid domain format — it must contain at least one dot (for example `myproject.local`). A plain name like `myproject` is not valid and Bearsampp will reject it.
</Warning>
