we have a few sites running on a wordpress turnkey. One of the sites is a multi-site from IIS I brought over. i have the apache server set for address of efg.com and servername of efg.com pointing to the directory it should. i have an ServerAlias of www.efg.com in the directive file. The problem is if i just go to efg.com it goes to a different server listed in the virtual hosts list, or will go to the main site of the multisite which isnt even created in the virtual host. DNS is setup for efg.com to go to the server ip and www.efg.com is a cname to go to server ip.

why would it find the server but not the right one?

 

Thanks,

Forum: 
Jeremy Davis's picture

I just checked and www.efg.com redirects to efg.com and the site displays fine for me?! So I assume you have it working as you want now?

Just in case, it's still not as you want and/or others that come across this thread, IMO the Apache docs are pretty good on Named based virtual hosts. There are also some name based virtual host examples.

It's also possibly worth noting that by default Apache (and therefore their docs) uses a single monolithic config file (often referred to as httpd.conf). On Debian (and therefore TurnKey) the Apache config is split into multiple files. E.g. the listening ports are configured in /etc/apache2/ports.conf. Usually individual sites are configured in /etc/apache2/sites-available/ E.g. /etc/apache2/sites-available/wordpress.conf and then enabled/disabled via the a2ensite/a2dissite commands. E.g. to enable the above noted WordPress site config: "a2ensite wordpress".

sorry should have clarified that efg.com was not the real address its just an example address

Jeremy Davis's picture

It's probably a good idea to avoid an example that really exists! Or at least make it one that is an obvious example; such as example.com or my-domain.com or similar. If it's your own site, then using the real URL can be even better though! As then we can check it real time.

Anyway, I'll respond to your other post that has details.

ya i didnt even think efg would be a real domain

Jeremy Davis

Thanks for the documentation I did read through it and knew about seperate files. I thought they were correct. Here is what I have.

 

DocumentRoot /var/www/efg
ServerName efg.com
ServerAlias www.efg.com *.efg.com
<Directory "/var/www/efg">
AllowOverride all
Require all granted
</Directory>

Jeremy Davis's picture

The virtualhost needs to be wrapped in tags. Using your example:

<VirtualHost *:80>
    ServerName efg.com
    ServerAlias www.efg.com *.efg.com
    DocumentRoot /var/www/efg
</VirtualHost>

<Directory "/var/www/efg">
    AllowOverride all
    Require all granted
</Directory>

If it's still not working, you'll need to look at other Apache config that you have enabled. My guess is that some other config is matching first, so this specific config is never getting matched.

I was wondering why they didnt have the <virtualHost > but thought it was becase they are all seperate hosts with seperate files.. i did look at the others after reading what you suggested and none of the others have the < virtual host> in them either. i can try adding that in but will probably be tomorrow or tonight.

 

Thanks

 

So the settings i copied into that last post were from apache - virtual hosts - and show directives but when i went into etc apache2 sites enabled and looked at the file in a file viewer i got the whole thing

I don't see anything wrong with it but maybe I'm missing something.

<VirtualHost ezliner.com:80>
DocumentRoot /var/www/EZLiner
ServerName ezliner.com
ServerAlias www.ezliner.com *.ezliner.com
<Directory "/var/www/EZLiner">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

 

 

sorry I misspoke... it does go to the dns record that says same as parent. so domain.com

Lucky's picture

Are you checking site on http or https, if https probably virtual host for port 443 may be conflicting somewhere. If not may be you can try with *:80 in virtualhost rather than domainname:80

Turned out it was something in the db that the web guy had to change due to the multi site. its working now. thanks for all the help.

Jeremy Davis's picture

Glad to hear it's working! :)

Add new comment