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

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

httpd.include for the vhost

<VirtualHost xx.xx.xx.xx:80>
    ServerName   mydomain.de:80
    ServerAlias   www.mydomain.de
    UseCanonicalName off
    SuexecUserGroup         mydomain psacln
    ServerAdmin  "info@mydomain.de"
    DocumentRoot /var/www/vhosts/mydomain.de/httpdocs

DNS Settings

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

	@       IN      SOA     ns.mydomain.de. info.mydomain.de. (
	                        1246541440      ; Serial
	                        10800   ; Refresh
	                        3600    ; Retry
	                        604800  ; Expire
	                        360 )   ; Minimum

	mydomain.de.           IN NS   ns.mydomain.de.
	mydomain.de.              IN NS   ns2.hans.hosteurope.de.
	ns.mydomain.de.                IN A
	mydomain.de.           IN A
	webmail.mydomain.de.           IN A
	mail.mydomain.de.              IN A
	science.mydomain.de.           IN A
	test.mydomain.de.              IN A
	testing.mydomain.de.           IN A
	ftp.mydomain.de.               IN CNAME        mydomain.de.
	www.mydomain.de.               IN CNAME        mydomain.de.
	*.webmail.mydomain.de.                 IN CNAME        mydomain.de.
	mydomain.de.           IN MX  10 mail.mydomain.de.
	mydomain.de.           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)
Host: www.mydomain.de
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
X-Pingback: http://mydomain.de/xmlrpc.php
Location: http://mydomain.de/
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from dezntpx01.computacenter.de
X-Cache-Lookup: MISS from dezntpx01.computacenter.de:8081
X-Cache: MISS from dezntpx03.computacenter.de
X-Cache-Lookup: MISS from dezntpx03.computacenter.de:8081
Via: 1.0 dezntpx01.computacenter.de:8081 (squid/2.7.STABLE5), 1.0 dezntpx03.computacenter.de:8081 (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/mydomain.de/httpdocs? 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

1 Answer 1

up vote 3 down vote accepted

Well, first thing is that this:

ServerName   mydomain.de:80
ServerAlias   www.mydomain.de

needs to be this:

ServerName    www.mydomain.de
ServerAlias   mydomain.de

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 www.mydomain.de 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.