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

标签 django apache apache2

我有一个网站 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 中的文件根
  • RedirectAlias 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/

    相关文章:

    Apache mod_proxy_ajp 模块过早地将流量发送到备用后端服务器

    perl - 梅森响应之前和之后的这些数字意味着什么?

    django - 如何在Django中添加简单的延迟任务?

    django - 无论修改时间如何,使 Django session 过期

    WordPress 和 Ubuntu,用于 FTP 的 www-data 和 ubuntu

    apache - 当我想从 http 重定向到 https 时,它会发送到另一个网站

    django - 运行时警告 : DateTimeField received a naive datetime

    javascript - Django:如何将 javascript var 作为 ajax 中的参数传递给 Django URL?

    apache2 - 在 LocationMatch 指令中使用否定

    php - 加载 xdebug 的 zend_extension 时本地主机站点出现黑屏问题? (Win 7, Apache 2.2, cakePHP 1.2)