0

I wanted to setup a local website using XAMPP. I did as their website said. I added the following to my C:\xampp\apache\conf\extra\httpd-vhosts.conf file:

virtual hosts screenshot

and the following to my C:\Windows\System32\Drivers\etc\hosts file:

hosts file screenshot

But yet on going to mypage.localhost I get the following error:

screenshot

Is there anything I'm doing wrong?

Thanks in advance...

  • 1
    Please post text as text, not images. – Scott Mar 12 at 7:43
  • thanks for the recommendation @Scott but when i tried to post it as text, the <VirtualHost*:80> and </VirtualHost> tags did not show up on the preview. – KILLERMAN2003 Mar 14 at 5:23
  • Paste it, select it, and type Ctrl+K — that will indent every line by four spaces, which will cause it to display correctly (see Anaksunaman's answer). Or just manually type four spaces before every line. – Scott Mar 14 at 5:57
  • thanks didn't know that. – KILLERMAN2003 Mar 14 at 7:15
0

You likely need to ensure that Apache has permission to access the directory:

<VirtualHost *:80>

    ServerName mypage.localhost
    DocumentRoot "C:\Users\SparklyZebra2019\Documents\css projects\CSS Main"

    # Controls general access permissions
    <Directory "C:\Users\SparklyZebra2019\Documents\css projects\CSS Main">
        Require all granted
    </Directory>

</VirtualHost>

This is necessary because you are attempting to access a directory outside the DocumentRoot set in httpd.conf (i.e. which already has certain permissions configured).

You can add additional directives as required. Using (roughly) the same global configuration options for the DocumentRoot specified in httpd.conf:

<VirtualHost *:80>

    ServerName mypage.localhost
    DocumentRoot "C:\Users\SparklyZebra2019\Documents\css projects\CSS Main"

    # Controls general access permissions and other options
    <Directory "C:\Users\SparklyZebra2019\Documents\css projects\CSS Main">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

</VirtualHost>
  • Indexes allows the directory contents to be shown if there is no e.g. index.html file.
  • FollowSymLinks tells Apache to follow symbolic links.
  • AllowOverride controls what directives may be placed in .htaccess files.

You can find more on the Options directive here and AllowOverride directive here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.