我有一个网站 example.com
和另一个 test.example.com
.两者都有不同的配置文件。但是当我输入 url test.example.com
它重定向到 example.com
.
configuration file for example.com
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DirectoryIndex index.html
DocumentRoot example-document-path
Options -Indexes
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/404.html
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['path', 'path'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE example.settings
PythonInterpreter example
PythonAutoReload On
PythonDebug On
</Location>
</VirtualHost>
test.example.com 的 Apache 配置文件
<VirtualHost *:80>
ServerName test.example.com
ServerAlias www.test.example.com
DirectoryIndex index.html
DocumentRoot test-example-document-path
Options -Indexes
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/404.html
<Location "/foo/bar/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['path', 'path'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE example.settings
PythonInterpreter example
PythonAutoReload On
PythonDebug On
</Location>
</VirtualHost>
根 url test.example.com 重定向到我不想要的 example.com?
我怎么一点头绪都没有?任何人都可以请建议吗?
提前致谢。
最佳答案
第一个猜测是缓存问题,第二个猜测是你的 index.html
(或 .php
或其他) test.example.com 上的文件。如果不是其中任何一个,请运行:
$ curl -vvv test.example.com
并查看其发回的 header 。他们会给你一些关于重定向性质的线索。如果这不能解决问题,请在此处发布输出。
编辑 :好的,如果您从 Apache 获得 302,那么可能负责的事情数量有限。想到的事情是:
.htaccess
test.example.com
中的文件根Redirect
和 Alias
Apache 配置中的指令 ( egrep -R 'Redirect|Alias' /etc/apache2/
) ModRewrite
带有重定向的规则 ( egrep -R '\bR\b' /etc/apache2/
) 此外,验证您实际上正在与您希望与之交谈的服务器交谈(例如,
curl http://test.example.com/blahblahblah
,然后 grep 访问日志 blahblahblah
)。
关于django - apache中test.example.com到example.com的重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4426575/