I'm trying to give my computer the priority on a domain name that isn't being broadcast: www.mythiddomain.com. I set up my vhosts file, like so:
<VirtualHost *:80>
ServerName mythirddomain.com
DocumentRoot "C:/www"
<Directory "C:/www">
Options +Indexes FollowSymlinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I tried editing my hosts file in multiple ways, including 127.0.0.1 mythirddomain.com and 198.168.1.2 mythirddomain.com, but I was just jabbing blind. I'm not sure what the next step is, after changing the vhosts file.
Action:
Browse to mythirddomain.com.
Expected result:
Get my index.php file.
Actual result:
Get inuit.com (they own mythirddomain.com).
Edit the following file:
%SystemRoom%\system32\drivers\etc\hosts
Add a line like this:
127.0.0.1 mythirddomain.com
This will obviously only have any effect on the local machine.
127.0.0.1 mythirddomain.comwas correct. The reason my browser wasn't resolving mythirddomain.com correctly is because I hadn't restarted my browser.
Related
I want to create or add local subdomain like test.localhost.com,
can you help me.
i tried to add this domain to my windows host file
127.0.0.1 test.localhost.com
it show page not working, what can i do?
first i want to tell you that windows hosts file can only redirect you to specify IP address only but localhost.com is not open by default in xampp so you have to add localhost.com manually.
Go To C:\xampp\apache\conf\extra\httpd-vhosts.conf and paste this code at footer.
# FOR test
NameVirtualHost test:80
<VirtualHost *:80>
<Directory "C:/xampp/htdocs/test">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName test
ServerAlias www.test
DocumentRoot "C:/xampp/htdocs/test"
</VirtualHost>
and Go to C:\Windows\System32\drivers\etc\hosts and give direction for redirection using this code as you already done.
paste this code at bottom.
127.0.0.1 test
I am trying to move my default htdocs folder from
/Applications/xamppfiles/htdocs/
to a folder on another partition at
/Volumes/Webserver/xampp/htdocs/
which happens to be the directory where XAMPP for Windows is installed, allowing me to use the same directory for my website project regardless whether I code on Windows or MAC.
(Note: I am using a Macbook Air with Bootcamp and ParagonNTFS, hence can read/write NTFS partitions)
I have successfully adjusted the httd.conf and vhost.conf files and managed to relocate the localhost directory to point to the files on the other volume, but I do NOT want to change the localhost directory, but rather create a new virtual host that points me to the other volume. So in short, I want these three domains
localhost -> /Applications/xamppfiles/htdocs/
site1.local -> /Volumes/Webserver/xampp/htdocs/project1/
site2.local -> /Volumes/Webserver/xampp/htdocs/project2/
The issue now is that when entering site1.local or site2.local into my browser, the browser redirects me to google because it cannot find the folders.
If I change the forward directory for localhost, things work fine.
localhost -> /Volumes/Webserver/campp/htdocs/project1/
Following config at play here:
httd.conf
DocumentRoot "/Volumes/Webserver/xampp/htdocs"
<Directory "/Volumes/Webserver/xampp/htdocs">
Include etc/extra/httpd-vhosts.conf
httpd-vhosts.conf
# Project1
<VirtualHost *:80>
ServerName site1.local
DocumentRoot "/Volumes/Webserver/xampp/htdocs/project1"
<Directory "/Volumes/Webserver/xampp/htdocs/project1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site1.local-error_log"
</VirtualHost>
# Project2
<VirtualHost *:80>
ServerName site2.local
DocumentRoot "/Volumes/Webserver/xampp/htdocs/project2"
<Directory "/Volumes/Webserver/xampp/htdocs/project2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site2.local-error_log"
</VirtualHost>
# localhost [must be included as the default named server]
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Volumes/Webserver/xampp/htdocs"
<Directory "/Volumes/Webserver/xampp/htdocs">
Require all granted
</Directory>
</VirtualHost>
I can access the localhost fine, but site1 and site2 dont work. If I change the documentroot of localhost, I can access fine though.
hosts
127.0.0.3 site2.local
127.0.0.2 site1.local
127.0.0.1 localhost
I tried assigning each site its own ip address, but without success.
Any help is much appreciated.
Had to restart about 10 times but now it seems the settings have taken effect. I can confirm the arrangement above works but requires a full restart in order to take effect.
I am trying to set up a virtualhost on my apple mac on localhost. The server is provided by XAMPP, which bundles Apache/MySQL/PHP in one bundle.
Here is what I have done so far:
Edited /private/etc/hosts to include 127.0.0.1 to point to test.myserver.local
127.0.0.1 test.myserver.local
Edited /Applications/XAMPP/etc/extra/httpd-vhosts.conf to inlcude my vhosts details
<VirtualHost *:80>
DocumentRoot /Users/???/Documents/workspace/trunk/htdocs
ServerName test.myserver.local
<Directory "/Users/???/Documents/workspace/trunk/htdocs">
AllowOverride All
</Directory>
</VirtualHost>
Placed a simple index.html in there with the word test in it.
I have restarted the server, and then browse to the test url to be greeted with Apache's default page instead of my test page.
The vhosts file works for another virtual host, the code is copied with the respective bits changed (i.e. folder paths), the hosts file works, as when Apache is turned off, my browser says server not found.
Why is Apache refusing to show up my test code? Are there any other files I need to change? I cant think of any others, its usually just those on linux/windows.
On xampp you need to edit 3 files to setup virtual hosts
the /etc/hosts and /Applications/XAMPP/etc/extra/httpd-vhosts.conf as you did.
But also you need to edit /Applications/XAMPP/xamppfiles/etc/httpd.conf to include the http-vhosts.conf
make sure you have uncommented this line
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
EDIT
Have you tried to add this lines
Order allow,deny
Allow from all
Just before the
AllowOverride All
Try leaving the the setting for "localhost" at the end of the file "httpd-vhosts.conf",
i.e.:
#
# Virtual Hosts
#
...
# others vhost
<VirtualHost *:80>
...
</VirtualHost>
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
#end of httpd-vhosts.conf file
Worked for me, greetings!
Have you told Apache to actually use name-based virtual hosting?
# Use name-based virtual hosting.
#
NameVirtualHost *:80
I don't believe it's enabled by default in Xampp on Mac.
I want to change XAMPP's htdocs directory. I followed the instructions to create a virtual host from this question:
Make XAMPP/Apache serve file outside of htdocs
this works fine on Windows 7, however when I try it on OSX, going to mysite.local just loads the xampp splash screen (mysite.local/xampp/index.html). I have restarted the web server. My virtual host declared in httpd-vhosts.conf is:
<VirtualHost *:80>
DocumentRoot Users/username/Documents/sitename.com
ServerName sitename.localhost
<Directory Users/username/Documents/sitename.com>
Order allow,deny
Allow from all
</Directory>
Open the following file in a text editor.
/Applications/XAMPP/xamppfiles/etc/httpd.conf
Search for "DocumentRoot", if the line below has a # in front of it than it's commented remove it and change the path between the quote
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
Now search for the line below and change the path between the quotes to your needs.
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
NOTICE: Paths similar to ~/ won't work use the absolute path.
I would like to expand this answer for 2022.
You will have to change 3 files if you want to keep web root in another directory. Let's say that you have installed XAMPP regularly, but your httpd directory is on another volume. Let's say in work/xampp/
Open /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf and change it to the following
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
We have added
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
and the block
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Open file /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf and change it to the following
<VirtualHost *:80>
DocumentRoot "/Volumes/work/xampp"
</VirtualHost>
<VirtualHost yoursite.mac:80>
ServerName yoursite.mac
ServerAlias www.yoursite.mac
ServerAdmin webmaster#yoursite.mac
DocumentRoot "/Volumes/work/xampp/yoursite.mac/webroot"
ErrorLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-error_log"
CustomLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-access_log" common
<Directory "/Volumes/work/xampp">
Require all granted
</Directory>
</VirtualHost>
Open /etc/hosts as a sudo and add your new site to it
127.0.0.1 yoursite.mac
If you forward to a directory in your user root, then:
DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">
Other than the answers mentioned above, I also had to change the line in XAMPP/xampfiles/etc/httpd.conf where it mentions username. the default was set to daemon and I changed it to my username; so there was no permission problem.
solved by editing httpd.conf
I have got this working. As per http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac, in OSX it is necessary to make two changes to httpd.conf, first, uncomment
#Include /Applications/xampp/etc/extra/httpd-vhosts.conf
and second, change the user from nobody to the username you use to log into OSX. You may also need to delete your browser's cache.
Using wampserver I can't get named virtual hosts to work. I've edited the httpd.conf to use the
Include conf/extra/httpd-vhosts.conf
I've added the domain to my system32/driver/etc/hosts file. I've edited the httpd-vhosts.conf file and everything seems to work except now localhost is unavailable. The domain I setup (test123.com) works fine, hitting 127.0.0.1 works fine, but hitting localhost hangs. There is nothing relevant in the error logs and no mention of it in the access logs. Here is how I have edited httpd-vhosts.conf:
#
# Virtual Hosts
#
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName test123.com
ServerAlias *.test123
# Folder where the files live
DocumentRoot "D:/Projects/html/test123"
# A few helpful settings...
<Directory "D:/Projects/html/test123">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
What am I doing wrong?
Finally figured it out. In httpd.conf I had to change
Listen 80
to
Listen *:80