I have three virtualhosts on my WAMP Stack, one works, the other gets 404'd
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
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.
Comments
Post a Comment