Multisite & Mod_Rewrite
am 27.12.2008 - 21:05 Uhr in
hi@all
bestimmt kennt ihr diesen Text in der .htaccess datei
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Nun habe ich aber 5 domains! Wie richte ich nun sowas ein das alle URL's die man aufruft ohne www. weitergeleitet werden!
- Anmelden oder Registrieren um Kommentare zu schreiben

RewriteCond %{HTTP_HOST}
am 27.12.2008 - 22:11 Uhr
RewriteCond %{HTTP_HOST} ^www\.domain1\.tld$ [NC]
RewriteRule ^(.*)$ http://domain1.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain2\.tld$ [NC]
RewriteRule ^(.*)$ http://domain2.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain3\.tld$ [NC]
RewriteRule ^(.*)$ http://domain3.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain4\.tld$ [NC]
RewriteRule ^(.*)$ http://domain4.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.domain5\.tld$ [NC]
RewriteRule ^(.*)$ http://domain5.tld/$1 [R=301,L]
Wunderbar es
am 27.12.2008 - 23:47 Uhr
Wunderbar es funktioniert.
Wie schaus eigentlich aus wenn man ohne .htaccess file arbeiten möchte?
Kann man einfach
RewriteCond %{HTTP_HOST} ^www\.domain1\.tld$ [NC]
RewriteRule ^(.*)$ http://domain1.tld/$1 [R=301,L]
^^virtualhost reinsetzen?
-------------------------------------------------------------------------------------
Die Logostik im Lager Lagerlogistik
Nette Seite
am 28.12.2008 - 02:32 Uhr
Nette Seite http://www.htaccesseditor.com/gr.shtml bookmarken :D
----------------------------------------
Alle Angaben ohne Gewähr!!:D
http://www.tobiasbaehr.de/
Ohne .htaccess (Apache) in settings.php (Drupal)
am 28.12.2008 - 12:41 Uhr
<?php
function custom_redir() {
global $base_url;
$base_host = parse_url($base_url, PHP_URL_HOST);
if ($_SERVER['HTTP_HOST'] == $base_host)
return;
$protocol = "http";
header('HTTP/1.1 301 Moved Permanently');
header('Location: '. $protocol .'://' . $base_host . '' . request_uri());
return;
}
custom_redir ();
?>
Setzt aber im Snippet vorraus, dass $base_url in der settings.php gesetzt ist. Geht natürlich auch hardcoded.