Virtual host installation not working

5,478

I get an error saying The webpage is not accessible.

There are several mistakes in your configuration.

Your host file:

127.0.0.1  //Mywebsite.dev
  • Remove the // from the entry in the hosts file.

Corrected hosts file:

127.0.0.1  Mywebsite.dev

Your httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot C:\Mywebsite\trunk\www\public
    ServerName //Mywebsite.dev    
    <Directory C:\Mywebsite\trunk\www\public>
        Order allow,deny
        Allow from all
    </Directory>   
</VirtualHost>
  • Remove the // from the ServerName

  • Replace \ with /

  • Quote the DocumentRoot and Directory

Corrected httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot "C:/Mywebsite/trunk/www/public"
    ServerName Mywebsite.dev    
    <Directory "C:/Mywebsite/trunk/www/public">
        Order allow,deny
        Allow from all
    </Directory>   
</VirtualHost>
Share:
5,478

Related videos on Youtube

NewPassionnate
Author by

NewPassionnate

Updated on September 18, 2022

Comments

  • NewPassionnate
    NewPassionnate over 1 year

    I am trying to instal my existing local server with xampp. I setup apache to point to mywebsite.dev document root to /code/www/public. I get an error saying The webpage is not accessible. This website has the same address as an external website.

    Instructions i m following:

    Create a folder on your computer for the files 
    Edit your host file to add the site name 
    Edit httpd-vhosts to add the VirtualHost 
    Restart Apache using the XAMPP Control Panel 
    
    
    127.0.0.1  //Mywebsite.dev
    
    <VirtualHost *:80>
        DocumentRoot C:\Mywebsite\trunk\www\public
        ServerName //Mywebsite.dev    
        <Directory C:\Mywebsite\trunk\www\public>
            Order allow,deny
            Allow from all
        </Directory>   
    </VirtualHost>
    
    • Patrick Mevzek
      Patrick Mevzek over 5 years
      Do not use .dev as a TLD locally you will run in all sort of problems. It is a valid generic TLD, owned by Google. You should not invent names locally and hope they will work and not create collisions. Instead create a domain name and then just name your resources locally like something.dev.example.com or something.internal.example.com or something.private.example.com, etc. About .DEV: ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hst‌​s
  • NewPassionnate
    NewPassionnate over 7 years
    it is saying forbidden access
  • DavidPostill
    DavidPostill over 7 years
    @NewPassionnate That's a different problem. Please post a new question.