Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I trying to keep the user on the url, but Apache uses a 301 Permament Redirect to .How can I prevent this?

httpd.include for the vhost

<VirtualHost xx.xx.xx.xx:80>
    UseCanonicalName off
    SuexecUserGroup         mydomain psacln
    ServerAdmin  ""
    DocumentRoot /var/www/vhosts/

DNS Settings

	; *** This file is automatically generated by Plesk ***
	$TTL    86400

	@       IN      SOA (
	                        1246541440      ; Serial
	                        10800   ; Refresh
	                        3600    ; Retry
	                        604800  ; Expire
	                        360 )   ; Minimum           IN NS              IN NS                IN A           IN A           IN A              IN A           IN A              IN A           IN A               IN CNAME               IN CNAME
	*                 IN CNAME           IN MX  10           IN TXT  "v=spf1 +a +mx -all"

Any Ideas, why this is happening? Thanks!

Edit: Thanks Chaos for your Input (cannot vote your answer up yet) , but unfortunately, it still doesn't work.

Fiddler2 Output

GET / HTTP/1.1
Accept: */*
Accept-Language: de
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 4.0.20506; InfoPath.2; .NET CLR 3.0.30729)
Proxy-Connection: Keep-Alive

HTTP/1.0 301 Moved Permanently
Date: Thu, 02 Jul 2009 18:38:34 GMT
Server: Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.5.1 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_python/3.3.1 Python/2.5.2 PHP/5.2.10 mod_perl/2.0.3 Perl/v5.8.8
X-Powered-By: PHP/5.2.10
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from
X-Cache-Lookup: MISS from
X-Cache: MISS from
X-Cache-Lookup: MISS from
Via: 1.0 (squid/2.7.STABLE5), 1.0 (squid/2.7.STABLE5)
Connection: keep-alive
Proxy-Connection: keep-alive
share|improve this question
Can you please provide some more information. What is the contents of /var/www/vhosts/ Is there any .htaccess files? – theotherreceive Jul 2 '09 at 18:33
I removed all the .htaccess files in the httpdocs dir. – Henrik P. Hessel Jul 2 '09 at 18:34
up vote 3 down vote accepted

Well, first thing is that this:


needs to be this:


UseCanonicalName should probably be on, too. If you want to keep them on one version of the site, it's helping you, not hurting you.

Edit: Okay, the problem is that your Apache server isn't even controlling the behavior you're seeing; the proxy you're talking to is. Why it's deciding to throw a 301 redirect isn't clear, but possibly it may be because is a CNAME record. I'd try making it an A record.

It may also take some arbitrary amount of time for the proxy to notice anything you're doing and adjust its behavior. For all I know, it could also have actual configured rules on it that are telling it to strip the www from your domain.

share|improve this answer
I removed several lines because of the apache modules. It's closed correctly. – Henrik P. Hessel Jul 2 '09 at 18:45
It's nothing to do with the CNAME, apache doesn't know or care about that. The www prefix being on the server alias rather than the server name would not cause apache to magically send 301 moved. – theotherreceive Jul 3 '09 at 1:40
Okay, that's great, but please now go back and read what I actually wrote. The 301 isn't being generated by Apache, it's being generated by a proxy, and what rules it uses to determine when it should send one are another matter entirely from Apache's. – chaos Jul 3 '09 at 9:09

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.