Apache virtual host 404 not found

20,592

Solution 1

  1. make sure there's file/htaccess/index or whatever in directory you want to open, 404 may comes from that ;)

  2. try using one below, eventually replace your port:

     <VirtualHost *:80>
         DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
         ServerName myphpwebsite.local
      </VirtualHost>
    
  3. the question is your Apache running/serving on port 8088? For example my xamp is running on 80 and 443...

  4. xamp control panel is very handy, it has nice logs button that will open your log files to show you php and apache errors etc. check it out.

Try going with default port, if it works it means that you need to play with ports if you really want to.

just a quick tip, .com is shorter than .local and if you're using chrome and it works like mine then most of the time something.local will redirect you to google search (and I like my search there, you can switch it off ;))

Solution 2

I don't know if I am much help, but using WAMP, here are my settings. I am listening on port 80, I use 8080 for my tomcat server.

hosts file

127.0.0.1  local.mysite.com

httpd-vhosts.conf

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

....

<Directory "c:/wamp/www">
    Options Indexes MultiViews FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "c:/wamp/www"
</VirtualHost>

<Directory "c:/wamp/www/path/to/site/root">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<VirtualHost *:80>
    ServerName local.mysite.com
    DocumentRoot "c:/wamp/www/path/to/site/root"

    ServerAdmin [email protected]

    ProxyPreserveHost Off
    RewriteEngine On
    AllowEncodedSlashes NoDecode
    #AllowEncodedSlashes On

    ErrorLog "c:/wamp/www/path/to/logs/error.log"
    CustomLog "c:/wamp/www/path/to/logs/access.log" common
</VirtualHost>

....

Then I can access my local site like this: http://local.mysite.com

Hope this helps...

Share:
20,592
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I just started learning php and I am trying to host locally my own php website by using XAMPP.

    I wanted to create virtual host with:

    URL: myphpwebsite.local

    Port: 8088

    But when I attempted to access this website through the browser I got a:

    Not Found HTTP Error 404. The requested resource is not found.

    Does anyone know what the problem is?

    My httpd-vhosts.conf

    NameVirtualHost 127.0.0.1:8088
    <VirtualHost 127.0.0.1:8088>
      DocumentRoot "C:/xampp/htdocs"
      ServerName localhost
    </VirtualHost>
    
    <VirtualHost myphpwebsite.local>
        DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
        ServerName myphpwebsite.local
        ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
        CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
    
       <Directory "C:/Microsoft/Workspace/myphpwebsite">
        Order allow,deny
        Allow from all
       </Directory>
    </VirtualHost>
    

    And my C:\Windows\System32\drivers\etc\hosts file:

    127.0.0.1       localhost
    127.0.0.1 myphpwebsite.local
    

    Any help would be appreciated!

  • Chris Brendel
    Chris Brendel about 9 years
    @Axvil If this still doesn't work, make sure the folder for your DocumentRoot actually exists and that Listen 8088 is in your httpd.conf. I've made sillier mistakes. :)