XAMPP Windows Apache vhosts not redirecting properly - apache

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
<Directory "C:/xampp/htdocs/">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/gl"
ServerName gl.dev
<Directory "C:/xampp/htdocs/gl">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The above is what I currently have in my vhosts file. When I hit localhost I want my root to open, but when I load gl.dev I want the individual site to open. Any ideas?
hosts file:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 gl.dev

I think in windows you have to use backslash when specifying document root. please try the following
<VirtualHost *:80>
ServerName localhost
ServerAlias *.localhost
DocumentRoot "C:\xampp\htdocs\"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gl.dev
ServerAlias *.gl.dev
DocumentRoot "C:\xampp\htdocs\gl"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Restart WAMP server

Related

why apache force me to use https?

i have a problem with apache2 on localhost
i have many virtualhost and thats worked fine before, but today i have a problem
when i try open test-bot.app apache force me to https://test-web.app!
this is my vhost file:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test-bot.app
ServerAlias test-bot.app
DocumentRoot /var/www/html/test-bot/public
<Directory />
AllowOverride All
</Directory>
<Directory /var/www/html/test-bot/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/apache2/test-bot.app-error.log
LogLevel error
CustomLog /var/log/apache2/test-bot.app-access.log combined
</VirtualHost>
what can i do?

Multiple Virtual Hosts not working

I am trying to set up two virtual hosts for one IP address say xxx.yy.xxx.yyy
I have my files on /var/www/html/folder1 and /var/www/html/folder2
I am adding VH like :
DocumentRoot /var/www/html/folder1
ServerName xxx.yy.xxx.yyy/folder1
AllowOverride All
DocumentRoot /var/www/html/folder12
ServerName xxx.yy.xxx.yyy/folder2
AllowOverride All
As I am new on CentOS7 Apache, can't figure out how to solve it.
I do not know if I can be helpful but I locally configure so apace to have multiple domains
<VirtualHost q4y.aurecchia.dev:80>
DocumentRoot "C:\xampp\htdocs\QuestManager\AurQuest4You\public"
ServerAdmin q4y.aurecchia.dev
<Directory "C:\xampp\htdocs\QuestManager\AurQuest4You">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost csm.aurecchia.loc:80>
DocumentRoot "C:\xampp\htdocs\CSM TEST\Aur_CSM\public"
ServerAdmin csm.aurecchia.loc
<Directory "C:\xampp\htdocs\CSM TEST\Aur_CSM">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Apache2 subdomain redirects to main domain

I have an EC2 instance setup running Ubuntu 14.04 and Apache. I have a single elastic IP serving multiple domains and subdomains all of which point to individual folders on the server. The problem I am having is unless the subdomain is explicitly set in my .conf it will redirect to the main domain. I can't seem to find a definitive answer here or in google.
I have a single .conf file residing in /etc/apache2/sites-enabled/ serving all of the domains and subdomains like so:
<VirtualHost *:80>
ServerAdmin me#mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html/mydomain.com
<Directory /var/www/html/mydomain.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#mydomain.com
ServerName sub1.mydomian.com
ServerAlias www.sub1.mydomain.com
DocumentRoot /var/www/html/sub1.com
<Directory /var/www/html/sub1.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#mydomain.com
ServerName sub2.mydomian.com
ServerAlias www.sub2.mydomain.com
DocumentRoot /var/www/html/sub2.com
<Directory /var/www/html/sub2.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#mydomain.com
ServerName mydomain2.com
ServerAlias www.mydomain2.com
DocumentRoot /var/www/html/mydomain2.com
<Directory /var/www/html/mydomain2.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
So if I go to sub1.mydomain.com or sub2.mydomain.com it gets properly routed. But if I type sub3.mydomain.com which does not exist in my .conf file it gets redirected to mydomain.com. I do not want this behavior. How do I resolve this?
You need to enable name based virtualhosts. Add below line before your first virtual host and restart apache.
NameVirtualHost :80

Vhosts not working

I have the following vhosts setup:
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Apache24\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost cake-photos.com:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Apache24\htdocs\cake-photos"
ServerName cake-photos.com
ServerAlias *.cake-photos.com
<Directory "C:\Apache24\htdocs\cake-photos">
Options Indexes FollowSymLinks
AllowOverride all
Require ip 127.0.0.1
</Directory>
</VirtualHost>
<VirtualHost fangwear.co.uk:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Apache24\htdocs\Fangwear 2014"
ServerName fangwear.co.uk
ServerAlias www.fangwear.co.uk
<Directory "C:\Apache24\htdocs\Fangwear 2014">
Options Indexes FollowSymLinks
AllowOverride all
# Require all granted
Require ip 127.0.0.1
</Directory>
</VirtualHost>
<VirtualHost manager.com:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Apache24\htdocs\Manager 2014"
ServerName manager.com
ServerAlias www.manager.com
<Directory "C:\Apache24\htdocs\Manager 2014">
Options Indexes FollowSymLinks
AllowOverride all
# Require all granted
Require ip 127.0.0.1
</Directory>
</VirtualHost>
None of it seems to be working and if I try to go to any of these I end up being redirected to the cake-photos.com vhost.
I need to be able to get to other things too such as localhost/phpmyadmin but that won't work with this configuration.
Where am I going wrong?
Did you set up your hosts file? On Unix Systems /etc/hosts? And did you restart your server?

correct setup of apache to handle multiple domains

hello i have 2 domains domain1.com,domain2.com
both are in the same server under domain1.com
i want to set the VirtualHost to handle them both
like this:
<VirtualHost domain1.com:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost domain2.com:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
but for some reason the server send me only to the first one
i also tryed it like this
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
anyone have any idea how to fix this problem ?
I think you are missing the NameVirtualHost directive.
NameVirtualHost *:80
<VirtualHost *>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
Without it your first VirtualHost will be used for all access when using name-based virtual hosting.