大网数据广告活动
网站运营与故障问答

I have three virtualhosts on my WAMP Stack, one works, the other gets 404'd

· 52CE 我爱测

Hi everyone I'm new both to this site and to backend web stuff. Thank you in advance for any and all help. Like I said in my title, I have three vhosts, two of which I can point the browser towards and one that gives me a 404. lo…

问题原文

原帖链接 · Nilco · CC BY-SA 3.0

Hi everyone I'm new both to this site and to backend web stuff. Thank you in advance for any and all help. Like I said in my title, I have three vhosts, two of which I can point the browser towards and one that gives me a 404. localhost and site1 both work, site2 doesn't. I think I've configured httpd-vhosts.conf correctly, but here's what it looks like.

 <VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "C:/wamp/www"
  <Directory "C:/wamp/www">
    Allow From All
    Require local
    Require ip 127.0.0.1
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName  site1.localhost
  ServerAlias site1
  DocumentRoot "C:/wamp/www/site1"
  <Directory "C:/wamp/www/site1">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
    Require ip my.local.network
  </Directory>
</VirtualHost>



#
<VirtualHost *:80>
    ServerName site2.localhost
    DocumentRoot "c:/wamp/www/site2"
    <Directory  "c:/wamp/www/site2/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        Require ip my.local.network
    </Directory>
</VirtualHost>

the system32/drivers/etc hosts file looks like this:

127.0.0.1 localhost

127.0.0.1 site1.localhost

127.0.0.1 site2.localhost

Which looks okay to me.

I'm think the problem stems from my server redirects in .htaccess in the site2 directory. But, again, the syntax looks correct. It's longer in real ife, but to save space, here's a sample. (note that this is an identical file to the one currently running live on site2.com and working just fine)

RewriteEngine On
Redirect 301 /index.html /index.php
Redirect 301 /products/foo.php /products/bar.php
Redirect 301 /products/bleep.php /products/blorp.php
Redirect 301 /literature/peep.pdf /literature/poop.pdf
Redirect 301 /products/product1.php /products/prodcut2.php

I think the problem is in here somewhere because when I try to go site2/index.php, it redirects me to products/product2.php and that's when I get the 404 error.

Checking my logs, I haven't gotten any PHP errors. But the apache log shows me this error after I try to access site2.localhost:

[Fri Apr 13 16:31:41.374431 2018] [mpm_winnt:notice] [pid 10660:tid 812] AH00418: Parent: Created child process 5852
[Fri Apr 13 16:31:41.842390 2018] [mpm_winnt:notice] [pid 5852:tid 756] AH00354: Child: Starting 64 worker threads.

Why is it starting so many processes? Is that the problem? What have I created!?!?

Edit: when I point my browser to site2.localhost, I get the 404. If I point it to site2.localhost/index.php it directs me to the wampserver homepage. Don't know if that helps

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

I would not recommend setting different DocumentRoots that are subdirectories of each other. Rather each site should have its own independent directory. I'd change your first virtual host to:

  DocumentRoot "C:/wamp/www/default"
  <Directory "C:/wamp/www/default/">

Create that directory, and move everything except site1 and site2 frow www into the default directory.

Once you do that you won't be able to access your sites as both subdirectories and subodmains. Doing so is what is causing your problems.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。