Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django apache中test.example.com到example.com的重定向问题_Django_Apache_Apache2 - Fatal编程技术网

Django apache中test.example.com到example.com的重定向问题

Django apache中test.example.com到example.com的重定向问题,django,apache,apache2,Django,Apache,Apache2,我有一个网站example.com,还有一个网站test.example.com。两者都有不同的配置文件。但当我输入urltest.example.com时,它会重定向到example.com configuration file for example.com <VirtualHost *:80> ServerName example.com ServerAlias www.example.com DirectoryIndex index.html Docu

我有一个网站
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>
example.com的配置文件
ServerName example.com
ServerAlias www.example.com
DirectoryIndex.html
DocumentRoot示例文档路径
选项-索引
ErrorDocument 404/errors/404.html
ErrorDocument 403/errors/404.html
SetHandler python程序
PythonHandler django.core.handlers.modpython
PythonPath“['path','path']+sys.path”
SetEnv DJANGO_设置_模块示例.SETTINGS
PythonInterpreter示例
蟒蛇
蟒蛇
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>

ServerName test.example.com
ServerAlias www.test.example.com
DirectoryIndex.html
DocumentRoot测试示例文档路径
选项-索引
ErrorDocument 404/errors/404.html
ErrorDocument 403/errors/404.html
SetHandler python程序
PythonHandler django.core.handlers.modpython
PythonPath“['path','path']+sys.path”
SetEnv DJANGO_设置_模块示例.SETTINGS
PythonInterpreter示例
蟒蛇
蟒蛇
根url test.example.com重定向到example.com,但我不想要? 我怎么不知道?谁能给我提个建议吗


提前感谢。

第一个猜测是缓存问题,第二个猜测是test.example.com上的
index.html
(或
.php
或其他)文件。如果不是其中任何一个,请运行:

$ curl -vvv test.example.com
看看它发送回来了什么。他们会给你一些关于重定向性质的线索。如果这不能解决问题,请在此处发布输出

编辑:好吧,如果你从Apache获得了一个302,那么你的责任是有限的。我想到的是:

  • test.example.com
    根目录中的
    .htaccess
    文件
  • Apache配置中的
    Redirect
    Alias
    指令(
    egrep-R'Redirect | Alias'/etc/apache2/
  • ModRewrite
    带有重定向的规则(
    egrep-R'\bR\b'/etc/apache2/

此外,请确认您实际上正在与您希望与之交谈的服务器交谈(例如,
curl
,然后为
blahblahblah
)grep访问日志。

这很可能与DNS设置有关。我怀疑这和Apache有什么关系。可能存在将test.example.com指向example.com的别名记录,或将*.example.com指向example.com的通配符别名记录

这不是一个真正的问题:如果这不是你想要的,那么你想要什么?@koneark,我认为test.example.com不应该被定向到example.com。你真的应该重命名你的问题以反映你想知道的内容。你不认为发布“test.example.com”的配置会更有用吗因为这是您试图访问的站点?@lqc;我更新了问题。嗨,大卫!curl请求的响应清楚地表明有302个,但它来自哪里,我们不知道?你能再解释一下吗?非常感谢。嘿,大卫,我也有同样的疑问。所以,我刚刚在这里发布了回复。嘿,伙计们,我更新了我的答案,增加了一些可能性。试试看它们是否管用。谢谢大卫。有一个.htaccess文件,此处写入了重新布线规则。在DNS test.example.com中是否已添加为记录?是因为这个吗?他们的是CNAME记录,例如.com是:CNAME(别名)记录名称:wwww.example.com。我怀疑这是DNS问题……没有任何办法会导致302重定向。如果有的话,DNS可能指向一个坏服务器(例如,
test.example.com
指向
old_server.example.com
),并且坏服务器上的Apache配置错误……是的,对不起,我没有意识到它得到了302重定向。但是你是对的,你提到的那些DNS设置都不会导致它重定向到其他域。请确保index.html文件也不会使用meta标记执行302重定向