Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been having a strange problem on a server I'm administering. After a certain amount time, without doing any change on the server, it suddenly starts redirecting to the main url plus some url info after that, without a slash, or it starts redirecting in a redirect loop to one of the main sites it's serving. For example, if i was serving the sites example,com from this server, going to example.com/something would suddenly redirect you to www.example.comsomething (no slash, thus an invalid url). There was a time also when it would go into a redirect loop with one of the main sites (i.e., redirecting example.com to example.com).

This all starts happening by itself after a certain amount of time (the first time was more than 2 months, now it's less than a week). If I simply restart apache, it's fixed and there's no problem for a while. The server is a new VPS running CentOS 6.3, which has had nothing done on it except for setting up two Django/WSGI sites.

I know that this is a difficult question to answer, but I'm not even sure how to get more information. Does anyone have any suggestions regarding where to look or check regarding what the problem might be?

EDIT: Here is the configuration for one of the two sites that the server is hosting. The configuration for the other site is nearly identical except for the exact domain name and the paths. Both these files are included in the main Apache configuration file via an Include directive.

<VirtualHost (server IP address):80>
    ServerName www.(domain name).co.uk
    ServerAlias www.(alternate domain name).co.uk www.(alternate domain name).org.uk
    ServerAlias (domain name).co.uk (domain name).org.uk (alternate domain name).co.uk
    ServerAlias (alternate domain name).org.uk
    Redirect / http://www.(domain name).org.uk
</VirtualHost>

<VirtualHost (server IP address):80>
    ServerAdmin webmaster@(domain name).org.uk
    ServerName www.(domain name).org.uk
    ServerAlias (domain name).no-ip.org
    UseCanonicalName On
    ErrorLog logs/(domain name).org.uk-error_log
    CustomLog logs/(domain name).org.uk-access_log common

    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript

    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio

    DocumentRoot /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/

    Alias /robots.txt /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/media/robots.txt
    Alias /favicon.ico /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/media/favicon.ico
    Alias /media/ /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/media/
    Alias /tracker/media/ /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/bunsen/tracker/media/

    WSGIScriptAlias / /var/www/vhosts/(domain name).org.uk/httpdocs/(project name)/apache/django.wsgi
</VirtualHost>
share|improve this question
    
I'm assuming that you already have some mod_rewrite rules setup in your apache config? I'd suggest turning on rewrite logging (and make sure that you have enough disk space for those logs; they can grow very big) to start with. –  Jenny D May 10 '13 at 6:54
    
Also edit your question and include any rewrite rules you use in it, ss well as any redirect directives. –  Graham Dumpleton May 10 '13 at 8:57
    
@Jenny D, thanks for the pointer about mod_rewrite logging. As you can see from the above config, it's using mod_alias and not mod_rewrite. I set RewriteLogLevel to 9 but it's not writing anything to the log file at the moment (while the site is working). –  sagittarian May 11 '13 at 23:29
    
No, since you are doing it all with alias, nod_rewrite logging won't help. Next step, then, is to look at the usual log files. But in this case I'd actually start looking at the django logs first - redirects can be issued from a web page as well as from the web server. –  Jenny D May 12 '13 at 6:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.