Apache redirecting to removed virtual host - apache

I have a strange issue with my Apache. I added a new virtual host and I noticed if I browse to it it redirects to another hosts home directory. I have host1, host2 and newly created host3. If I browse to address for host 3 it would take me to host1 site.
I removed host1 now but it still trying to take me to host1 (Apache log has"
[Thu Jul 24 16:31:33 2014] [error] [client 127.0.0.1] File does not exist: C:/WWW/htdocs/public/host1/index.html " which is home directory for host1 site which is removed from httpd.conf. Apache service restarted, all other .conf files checked - no mentioning of host1.
here how its configured:
################# host2 ############################
<VirtualHost host2.net:80>
DocumentRoot "C:/WWW/htdocs/host2/public/"
ServerName host2
ServerAlias host2.local
<Directory "C:/WWW/htdocs/host2/public/">
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
################# host3 ############################
<VirtualHost host3.net:80>
DocumentRoot "C:/WWW/htdocs/host3/public/"
ServerName host3
ServerAlias host3.local
<Directory "C:/WWW/htdocs/host3/public/">
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks

In case anybody have the same issue - I just found one software on my PC that has been messing with port 80. Once that software removed - my apache works fine

Related

virtual host for xampp on Mac

in my httpd-vhost.conf on macos 10.15.4,
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/theb/"
ServerName theb.localhost
ServerAlias www.theb.localhost
#DirectoryIndex index.html
<Directory "/Applications/XAMPP/xamppfiles/htdocs/theb">
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
ErrorLog "logs/theb.local-error_log"
</VirtualHost>
I have also included the virtual host in httpd.conf
Include etc/extra/httpd-vhosts.conf
Then in the host file, i have
127.0.0.1 localhost
127.0.0.1 www.theb.localhost
The issue im facing now with these configs is that whenever i browse the site in my browser,
http://www.theb.localhost, i will then be redirected to http://www.theb.localhost/dashboard ( which is the xampp default project folder). did i miss something out??
Restart Apache. Hopefully that will work.
If you have downloaded the VM version of Xampp (The one that gets mounted) then this wont work as it doesn't have access to your local files, get the non VM one here https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/7.4.6/xampp-osx-7.4.6-0-installer.dmg/download

XAMPP Virtual Hosts not working

Before marking this as answered, please read the entire thing because yes there is a good amount of these questions but NONE of the answers on them have worked at all.
For the last 6 months I've looked at around 50 different form posts here and around the web to try and get my XAMPP virtual hosts working.
Hosts File
127.0.0.1 localhost
127.0.0.1 vws.localhost
127.0.0.1 instancegaming.net
127.0.0.1 vws.instancegaming.net
http-vhosts File (Updated 7/26)
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
# NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
<Directory "C:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
I'm at a loss of what to do, I've tried putting all fields to localhost then to instancegaming.net but nothing seems to work. I've read the Apache log and there's only SSL errors floating around.
When I try going to [ http:// ] vws.localhost, vws.192.168.0.47, vws.instancegaming.net all of which give the same error in chrome:
ERR_NAME_NOT_RESOLVED
Then I tried emptying chromes host cache, but that didn't help either.
Sidenote: I reinstalled XAMPP 4 times trying to make this work.
Follow these steps if you are in windows environment (7 & 10 tested) with XAMPP:
Add in hosts file [C:\Windows\System32\drivers\etc]
127.0.0.1 vws.localhost
127.0.0.1 instancegaming.net
127.0.0.1 vws.instancegaming.net
Add this in httpd.conf [C:\__Server\apache\conf] . though some says there are security risks with this but couldn't find a way without this
<Directory />
AllowOverride none
Require all granted
</Directory>
Add these in httpd-vhosts.conf [C:\__Server\apache\conf\extra]
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\__Server\htdocs"
<Directory "C:\__Server\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName tools.com.at
DocumentRoot "E:\phpStorms\git\tools-class"
SetEnv APPLICATION_ENV "development"
<Directory "E:\phpStorms\git\tools-class">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName laravel.test.com.at
DocumentRoot "E:\laravel.test.com.at\public"
SetEnv APPLICATION_ENV "development"
<Directory "E:\laravel.test.com.at\public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
template of this
<VirtualHost *:80>
ServerName nameInHostsFile
DocumentRoot "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot"
SetEnv APPLICATION_ENV "development"
<Directory "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Note 1: My xampp installed on C:\__Server location
Note 2 : My folder name is laravel.test.com.at and its in E: drive E:\laravel.test.com.at
Note 3: Always copy folder location from address bar in windows explorer, so there is no mistakes.
Note 4: You must restart XAMPP after editing httpd-vhosts.conf every time.
Note 5: Use uncommon part in url [i.e .com.at] so that it is unique and there is no issue resolving dns.
Update: troubleshoot#Jacob Jewett
After a fresh copy of XAMPP installation in C drive -
just add/append these line in httpd-vhosts.conf file
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
<Directory "C:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName vws.localhost
DocumentRoot "C:\xampp\vws"
SetEnv APPLICATION_ENV "development"
<Directory "C:\xampp\vws">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Add append this in httpd.conf file
<Directory />
AllowOverride none
Require all granted
</Directory>
ADD PATH variable for php [C:\xampp\php], and also check that there isn't another php path in the PATH variable.
restart xampp and browse localhost
Additionally make sure that the line
Include etc/extra/httpd-vhosts.conf
is not quoted out in httpd.conf
The answer I found that works is to to this in the hosts file.
192.168.0.47 localhost somthing.instancegaming.net
One thing I'd like to add here: For anyone who is sure everything is setup correctly, make sure you don't use any underscores in the alias string within your hosts file; for some reason it can't accept underscores.
I have similar issue, vhosts not working. But in my case I found there was the permission issue with host file. Hope this helps for some one. hosts file ignored, how to troubleshoot?
If pings are successful but a Virtual Host is not working with XAMPP 7.3.1 and Windows 10 Pro the problem may be interference with the World Wide Web Publishing Service.
On my system, Apache and MySQL start successfully but the virtual host cannot be browsed till I stop the WWWPS service (in Windows Services). The virtual host then becomes instantly available. It instantly stops working when the WWWPS is started again.
I fixed the problem by just restarting my computer after setting up the System32 file hosts and the apache vhosts.

Apache virtualhost on another port

I have mamy virtualhosts on Apache server (Arch Linux) and they are on hosts like 127.0.0.2, 127.0.0.10 and so on. One of them i want to make available from local network, so I could use address like 192.168.1.100 to get resources from that server, but I don't want to use default port. Now I have such configuration on /etc/httpd/conf/extra/httpd-vhosts.conf
<VirtualHost 127.0.0.1:8324>
DocumentRoot "/home/dominik/Dropbox/dev/SOMEAPP/root"
<Directory /home/dominik/Dropbox/dev/SOMEAPP/root>
DirectoryIndex index.php
Options +Indexes +FollowSymLinks +MultiViews +Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
It works perfect on local machine using localhost or 127.0.0.1, but when using lan address on port 8324, i get default apache site (like I make request on port 80)
curl 127.0.0.1:8324
HTML from SOMEAPP is returned
curl 192.168.1.100:8324
Default Apache index is returned
My /etc/hosts:
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
#::1 localhost.localdomain localhost
127.0.0.2 xx.tu xx.tu
# 127.0.0.3 xxxxx.tu xxxxx.tu
127.0.0.4 xxxxxxxx.tu xxxxxxxx.tu
127.0.0.5 xxxxxxxxxxx.tu xxxxxxxxxxx.tu
127.0.0.6 xxxxx.tu xxxxx.tu
127.0.0.10 xxxxxxx xxxxxxxx
I'd be glad if someone have some idea. Thanks.
Probably a SuperUser question, anyway:
<VirtualHost 192.168.1.100:8324>
DocumentRoot "/home/dominik/Dropbox/dev/SOMEAPP/root"
<Directory /home/dominik/Dropbox/dev/SOMEAPP/root>
DirectoryIndex index.php
Options +Indexes +FollowSymLinks +MultiViews +Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
p.s. you might want to modify your httpd configuration to avoid receiving the default apache index when you call the apache server with an Ip which doesn't correspond to any defined virtualhost

403 Forbidden Error setting up Virtual Hosts

I've run into this problem on other servers before, but this time I can't figure it out. I've tried looking at all the solutions on Stack Overflow, but no luck so far.
The Error: domain1 works just fine, but trying to access the index on domain2 fails.
Forbidden
You don't have permission to access /index.html on this server.
My httpd.conf
Note: domain1 is a symfony site, so the web root is /web, where as domain2 is just a static html site.
LoadModule vhost_alias_module modules/mod_vhost_alias.so
DocumentRoot "/var/www/html/domain1.com/web"
<Directory "/var/www/html/domain1.com/web">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin jason#domain2.com
DocumentRoot /var/www/html/domain2.com
ServerName domain2.com
ErrorLog logs/domain2.com-error_log
CustomLog logs/domain2.com-access_log common
</VirtualHost>
<Directory "/var/www/html/domain2.com">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
ls -l in /var/www/html
drwxr-xr-x 2 apache apache 4096 Jan 12 17:06 domain2.com
drwxr-xr-x 8 apache apache 4096 Jan 12 15:58 domain1.com
Other
I've already tried disabling selinux with "setenforce 0"
I've made sure to restart apache each time after changing httpd.conf by running "service httpd restart"
I've rebooted the server itself
Apache Version: 2.2.15
CentOS Version: 6.5

Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7.
As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.
This is what I added to my httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ServerAlias www.dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>
So I looked up my dropbox.local-error.log for any information:
[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
This error seems to be solved by adding
<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
Allow from all
</directory>
But now I get this error in dropbox.local-error.log:
[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/
Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.
Can anybody help... It's driving me mad :S
EDIT:
Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
Okay: This is what I did now and it's solved:
My httpd-vhosts.conf looks like this now:
<VirtualHost dropbox.local:80>
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
<Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>
</VirtualHost>
First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory>-part INSIDE the <VirtualHost > [..] </VirtualHost>.
After that, I added AllowOverride AuthConfig Indexes to the <Directory> options.
Now http://localhost also points to the dropbox-virtualhost. So I added dropbox.local to <VirtualHost *:80> which makes it as <VirtualHost dropbox.local:80>
FINALLY it works :D!
I'm a happy man! :) :)
I hope someone else can use this information.
For me worked when I changed "directory" content into this:
<Directory "*YourLocation*">
Options All
AllowOverride All
Require all granted
</Directory>
For me (also XAMPP on Windows 7), this is what worked:
<Directory "C:\projects\myfolder\htdocs">`
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>`
It is this line that would cause the 403:
Order allow,deny
I'm using XAMPP 1.6.7 on Windows 7. This article worked for me.
I added the following lines in the file httpd-vhosts.conf at C:/xampp/apache/conf/extra.
I had also uncommented the line # NameVirtualHost *:80
<VirtualHost mysite.dev:80>
DocumentRoot "C:/xampp/htdocs/mysite"
ServerName mysite.dev
ServerAlias mysite.dev
<Directory "C:/xampp/htdocs/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After restarting the apache, it were still not working.
Then I had to follow the step 9 mentioned in the article by editing the file C:/Windows/System32/drivers/etc/hosts.
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
Then I got working http://mysite.dev
Thank you, that worked! But I replaced this
AllowOverride AuthConfig Indexes
with that
AllowOverride All
Otherwise, the .htaccess didn't work: I got problems with the RewriteEngine and the error message "RewriteEngine not allowed here".
Above suggestions didn't worked for me. I got it running on my windows, using inspiration from
http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html
For Http inside httpd-vhosts.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
For using Https (Open SSL) inside httpd-ssl.conf
<Directory "D:/Projects">
AllowOverride All
Require all granted
</Directory>
##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev
</VirtualHost>
Hope it helps someone !!
After so many changes and tries and answers.
For
SOs: Windows 7 / Windows 10
Xampp Version: Xampp or Xampp portable 7.1.18 / 7.3.7 (control panel v3.2.4)
Installers: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer
Do not edit other files like httpd-xampp
Stop Apache
Open httpd-vhosts.conf located in **your_xampp_directory**\apache\conf\extra\ (your XAMPP directory might be by default: C:/xampp/htdocs)
Remove hash before the following line (aprox. line 20): NameVirtualHost *:80 (this might be optional)
Add the following virtual hosts at the end of the file, considering your directories paths:
##127.0.0.1
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
##127.0.0.2
<VirtualHost *:80>
DocumentRoot "F:/myapp/htdocs/"
ServerName test1.localhost
ServerAlias www.test1.localhost
ErrorLog "logs/myapp-error.log"
CustomLog "logs/myapp-access.log" common
<Directory "F:/myapp/htdocs/">
#Options All # Deprecated
#AllowOverride All # Deprecated
Require all granted
</Directory>
</VirtualHost>
Edit (with admin access) your host file (located at Windows\System32\drivers\etc, but with the following tip, only one loopback ip for every domain:
127.0.0.1 localhost
127.0.0.2 test1.localhost
127.0.0.2 www.test1.localhost
For every instance, repeat the second block, the first one is the main block only for "default" purposes.
I am using xampp 1.7.3. Using inspiration from here: xampp 1.7.3 upgrade broken virtual hosts access forbidden
INSTEAD OF add <Directory> .. </Directory> in httpd-vhosts.conf, I add it in httpd.conf right after <Directory "D:/xampplite/cgi-bin"> .. </Directory>.
Here is what I add in httpd.conf:
<Directory "D:/CofeeShop">
AllowOverride All
Options All
Order allow,deny
Allow from all
</Directory>
And here is what I add in httpd-vhosts.conf
<VirtualHost *:8001>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "D:/CofeeShop"
ServerName localhost:8001
</VirtualHost>
I also add Listen 8001 in httpd.conf to complete my setting.
Hope it helps
For many it's a permission issue, but for me it turns out the error was brought about by a mistake in the form I was trying to submit. To be specific i had accidentally put a "greater than" sign after the value of "action". So I would suggest you take a second look at your code.