redirection problem for test.example.com to example.com in apache
I have a site example.com
and another one test.example.com
. Both have different configuration file. But when I enter url test.example.com
it redirects to 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>
Apache configuration file for test.开发者_StackOverflow社区example.com
<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>
The root url test.example.com redirects to example.com which i don't want? How i have no clue? Can anyone please suggest something?
Thanks in advance.
First guess would be cache issue, second guess would be your index.html
(or .php
or whatever) file on test.example.com. If it's not either of those, run:
$ curl -vvv test.example.com
And see what headers its sending back. They will give you some clues about the nature of the redirect. If that doesn't solve it, post the output here.
Edit: Alright, if you're getting a 302 from Apache, there is only a limited number of things that could be responsible. The things that come to mind are:
.htaccess
file in thetest.example.com
rootRedirect
andAlias
directives in Apache config (egrep -R 'Redirect|Alias' /etc/apache2/
)ModRewrite
rules with redirects (egrep -R '\bR\b' /etc/apache2/
)
Also, verify that you're actually talking to the server you expect to be talking to (eg, curl http://test.example.com/blahblahblah
, then grep the access log for blahblahblah
).
Most likely this has to do with the DNS settings. I doubt it has anything to do with Apache. There is probably an alias record pointing test.example.com to example.com OR a wildcard alias record pointing *.example.com to example.com.
精彩评论