Can you tell me please what am I doing wrong in Virtual host settings?
I am editing two files:
Apache/conf/extra/httpd-vhosts.conf and Windows/System32/drivers/etc/hosts
httpd-vhosts.conf looks like
<VirtualHost 127.0.0.1>
ServerName scouttautomotive.com
ServerAlias www.scouttautomotive.com
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bosp.sk
ServerAlias bosp.sk.localhost
DocumentRoot "C:/Apache24/htdocs/bosp/web"
</VirtualHost>
hosts file looks like
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 scouttautomotive.com
127.0.0.1 bosp.sk
What is wrong with it? I am realy confused cause bosp.sk virtual host works well.
After setting the domain ip to 127.0.0.1 to host file, You must restart your computer or flush dns cache to get that applied. Did you do?
So look at these config files and note that difference is only in the last letter of ServerName.
httpd-vhosts.conf
<VirtualHost 127.0.0.1>
ServerName scouttautomotive.com
ServerAlias scout.com.localhost
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName scouttautomotiv.com
ServerAlias drom.com.localhost
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
hosts
127.0.0.1 scouttautomotive.com
127.0.0.1 scouttautomotiv.com
First version redirects me to one hosting which offers this domain to sell. Second version works well as virtual host. Both are created in the same time. So it looks command ipconfig /flushdns may not be enough.
Another possible solutions can be find here https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot Good luck!
Related
I am new to Laravel and while creating a new project, I wanted it to be named in Virtual Host. By this way,
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
I named it, defined IP address for it (127.0.0.1) in HOSTS file but now, when I write localhost/ in the address bar, instead of going to Xampp("Welcome to XAMPP"), it goes to my laravel project. I know that if I will define my localhost the same way, like
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
the problem will be solved but I don't know the reason of doing this. Why do I need to name C:/xampp/htdocs/ as localhost, if it was default before my laravel project?
if i get your meanings correct, you need add a default virtual host before other virtual host, so in your case, should be like this,
add the code block to end of the httpd.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
and edit hosts file to
127.0.0.1 localhost
127.0.0.1 logo.local
I moved from linux to a mac. I have Apache and php setup.
Now apache seems to only load the first virtual host listed. It also only loads it in the browser via local host and not the sitename. Its been 3 days hunting the net or solutions nothing seems to work.
now if i make the document root for the virtual host eg. /Library/WebServer/Documents/ then it works. If i add an extra directory it fails eg. /Library/WebServer/Documents/livingahimsa.co.uk
here is the config: ( I have tried the doc root with quotes and without)
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 ahimsainvestments.com
127.0.0.1 livingahimsa.co.uk
127.0.0.1 ahimsavillage.com
255.255.255.255 broadcasthost
::1 localhost
and vhost:
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/ahimsainvestments.com
ServerName ahimsainvestments.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/livingahimsa.co.uk
ServerName livingahimsa.co.uk
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/ahimsavillage.com
ServerName ahimsavillage.com
pache2/httpd.conf
I'm facing below issue while use XAMPP in windows. Same working if I connect with VPN.
Unknown Host
Description: Unable to locate the server named "d8.kali" --- the server does not have a DNS entry. Perhaps there is a misspelling in the server name, or the server no longer exists. Double-check the name and try again.
C:\Windows\System32\drivers\etc: hosts
127.0.0.1 localhost
127.0.0.1 d8.kali
C:\xampp\apache\conf\extra: httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/drupal-8"
ServerName d8.kali
ErrorLog "logs/d8.kali-error.log"
CustomLog "logs/d8.kali-access.log" common
</VirtualHost>
Edit:
I have this setup in my local system.
As per below comment, used IP. Even not working.
127.0.0.1 localhost
#.#.#.#(IP) d8.kali
I want to forward different domain names to single IP Address (local for testing), but how can i recognize in pc that which domain name should be linked to which folder?
for example, in windows host file, I wrote
127.0.0.1 abc.com
127.0.0.1 test.abc.com
127.0.0.1 test1.abc.com
Being found within the same VirtualHost section binds the ServerName and DocumentRoot directives together.
<VirtualHost *:80>
ServerName www1.example.com
DocumentRoot /srv/web/www1
</VirtuaHost>
<VirtualHost *:80>
ServerName www2.example.com
DocumentRoot /srv/web/www2
</VirtuaHost>
I am using XAMPP, Apache 2.2.17. I have added virtual host but my virtual host and localhost both point to the same location. Here is my code in httpd-vhosts.conf
<VirtualHost www.domain.tld:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/testsite"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
With the above code, I get testsite with www.domain.tld so that is good. But If i type localhost, it will go to testsite as well. If I move ahead of test site then localhost goes to localhost good and www.domain.tld goes to localhost too. I tried different setting for localhost as like
<VirtualHost *>
<VirtualHost localhost:80>
and removing *.domain.tld from domain.tld but nothing works. Am I missing something obvious?
My own answer: The following code fixed the problem
<VirtualHost *:80> <--- * fixed the problem, apache 2.2 doc does say it must match www.domain.tld, which caused problem for other Virtual hosts
ServerName www.domain.tld
ServerAlias domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/patriot2"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
please change your ServerName from virtualhost to a local IP address such as 127.0.0.2.
ServerName domain.tld is an example of using "domain.com" where .tld is replaced by .com for your domain.