Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Apache, Lighttpd, nginx, Cherokee
Post Reply
markus3915
Posts: 5
Joined: 2005-06-16 00:20
 

Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Post by markus3915 »

Hallo Forum,

ich stehe gerade vor dem Problem alle Anfragen auf eine Website auf eine Domain zu leiten. d.h. Benutzer gibt ein domain.de oder xx.domain.de oder zz.domain.de und landet immer automatisch auf http://www.domain.de

Hierzu habe ich folgendes in der Apache-Config:

RewriteCond %{HTTP_HOST} !^www.domain.de$
RewriteRule ^(.*)$ http://www.domain.de/$1 [L,R=301]

Rufe ich xxx.domain.de auf lande ich auf http://www.domain.de
Rufe ich xxx.domain.de/index.php auf -> http://www.domain.de/index.php

Beim Aufruf von xxx.domain.de/dir/file.php wir die Domain nicht ausgetauscht und ich kann auf die Datei zugreifen.

Wer kann mir einen Tipp geben, dass dies auch funktioniert?

Danke,
Markus
static
Posts: 437
Joined: 2002-10-27 19:56
Location: Schweiz
 

Re: Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Post by static »

Hi markus
Warum über RewriteRules?

Ein Server Alias mit Wildcard und entsprechendem Redirect wäre doch sinnvoller...

.static
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Post by Joe User »

Code: Select all

<VirtualHost *:80>
    ServerName www.domain.tld
#   ...other options...
</VirtualHost>
<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias *.domain.tld
    Redirect permanent / http://www.domain.tld/
</VirtualHost>
markus3915
Posts: 5
Joined: 2005-06-16 00:20
 

Re: Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Post by markus3915 »

Danke für den Tip, leider bekomme ich im Mozilla Firefox die Meldung:

Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked.

Liegt es daran, dass ich nur:

Code: Select all

Redirect permanent / http://www.domain.tld/
eingefügt habe, da

Code: Select all

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias *.domain.tld
</VirtualHost>
schon vorhanden war?

Ok, ich habs: Ich habe eine Endlosschleife gebaut. ;)

Allerdings bekomme ich die Meldung:
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) [Thu Jun 16 23:38:00 2005] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
done
markus3915
Posts: 5
Joined: 2005-06-16 00:20
 

Re: Weiterleitung aller Anfragen auf bestimmte URL (RewriteRule)

Post by markus3915 »

Hat vielleicht Jemand einen Tipp wie man das trotzdem hinbekommt?
Post Reply