rediriger vers www

Nouveau WRInaute
J'essaye de rediriger tous les sous domaines vers le sous-domaines www.

J'ai donc mis dans mon htacces:
Code:
RewriteBase /
RewriteCond %{HTTP_HOST} ^mondomaine.com$
RewriteRule ^(.*)   http://www.mondomaine.com/$1 [QSA,L,R=301]

Mais il ne semble pas prendre en compte la redirection?
ou plus exactement il redirige
http://mondomaine.com > http://www.mondomaine.com
mais pas
http://w.mondomaine.com > http://www.mondomaine.com

en revanche
Code:
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mondomaine.com [NC]
RewriteCond %{HTTP_HOST} !^www\.mondomaine.com [NC]
RewriteRule ^(.*) http://www.mondomaine.com/$1 [QSA,L,R=301]
redirige

http://w.mondomaine.com > http://www.mondomaine.com
mais pas
http://mondomaine.com > http://www.mondomaine.com

Comment puis je rediriger
http://mondomaine.com & http://w.mondomaine.com > http://www.mondomaine.com
 
WRInaute discret
Personnellement, j'ai mis en place ce code dans le .htaccess qui fonctionne pour la redirection de mondomaine.com vers http://www.mondomaine.com :
Code:
RewriteCond %{HTTP_HOST} ^mondomaine.com$
RewriteRule ^(.*) http://www.mondomaine.com/$1 [QSA,L,R=301]

Par contre je n'ai jamais essayé de rediriger du w.mondomaine.com ou du ww.mondomaine.com qui donnent de toute façon une page web inaccessible.

Par contre attention si comme moi tu utilises déjà de l'url rewriting, il faut placer cette redirection 301 en début de fichier, avant les réécritures d'url.
 
Discussions similaires
Haut