The thing is that I have a django project installed in a subdomain in localhost and at the same time I have the localhost for other stuff without Django.
Whenever I access a1.localhost it displays my django welcome page ok, but when I want to access just localhost it also displays the same django welcome page instead of the index.html.
So far this is what I have:
Hosts:
127.0.0.1 localhost
127.0.0.1 a1.localhost
vhosts.conf:
#-- a1.localhost
<VirtualHost *:80>
ServerName a1.localhost
WSGIScriptAlias / "C:/workspace/website1/apache/django.wsgi"
<Directory "C:/workspace/website1/apache">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#-- localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/workspace/website1/django_project"
</VirtualHost>
django.wsgi
import os
import sys
path = "C:/workspace/website1/apache/django_project"
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'
import django.core.handlers.wsgi
What I want to achieve is to display my normal index.html file in localhost and my django project in a1.localhost.
Thanks.
I think what’s happening here is the first virtual host accepts all traffic to port 80 and redirects it to the django app. The second virtual host is not receiving traffic at all. The whole thing works when they’re different ports, because in that case apache knows which virtualhost should receive the traffic.
You might need to add a line before these declarations to set up the virtualhost naming, as Kay Zhu mentioned:
NameVirtualHost *:80
See this article for more information:
http://digitalpbk.blogspot.com/2007/01/making-subdomains-on-localhost.html