开发者

Apache/Django subdomains problem

开发者 https://www.devze.com 2022-12-29 22:56 出处:网络
Now I开发者_如何转开发 have apache configuration which works only with localhost domain (http://localhost/).

Now I开发者_如何转开发 have apache configuration which works only with localhost domain (http://localhost/).

Alias /media/ "/ścieżka/do/instalacji/django/contrib/admin/media/"
Alias /site_media/ "/ścieżka/do/plikow/site_media/"
<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    PythonPath "['/thomas/django_projects/project'] + sys.path"
    PythonDebug On
</Location>
<Location "/site_media">
SetHandler none
</Location>

How can I make it working for some subdomains like pl.localhost or uk.localhost? This subdomains should display the same page what domain (localhost).

Second question: It is possible change default localhost address (http://localhost/) to (http://localhost.com/) or (http://www.localhost.com/) or something else?


You can use the ServerAlias directive in apache for different hosts

NameVirtualHost *
<VirtualHost *>
ServerAlias pl.localhost
ServerAlias uk.localhost
Alias /media/ "/ścieżka/do/instalacji/django/contrib/admin/media/"
Alias /site_media/ "/ścieżka/do/plikow/site_media/"
<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    PythonPath "['/thomas/django_projects/project'] + sys.path"
    PythonDebug On
</Location>
<Location "/site_media">
SetHandler none
</Location>
</VirtualHost>

but if you dont use internet domains with a configured dns you need also to update yor hosts file with the hosts you are trying to use.


yes thanks Meska, I resolved the problem. I added to /etc/hosts file something like:

127.0.0.1 pl.localhost

127.0.0.1 uk.localhost

127.0.0.1 www.localhost.com

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号