Redirection 301 marche pas

Nouveau WRInaute
Bonjour

quelqu'un peut me dire pourquoi mes rediction sont en 302 au lieu de 301 ?

Quelle erreur ai je fais dans mon script ?

Voici mon script :

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ancien.com/jp/$ [NC]
RewriteRule ^(.*)$ http://www.nouveau.jp/ [QSA,L,R=301]
RewriteRule ^htm/product/mp/integrat/prod/prod.htm$   http://www.nouveau.com/htm/product/mp/integrat/prod/prod.php [QSA,L, R=301]

Merci pour votre aide
 
WRInaute accro
Bonjour,

Le problème est que www.ancien.com/jp/ n'est pas le nom du host (le nom du host, c'est www.ancien.com).

J'essaierais comme ceci:
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ancien.com$ [NC]
RewriteRule ^jp/(.*)$ http://www.nouveau.jp/ [QSA,L,R=301]
Tu veux tout rediriger vers la page d'accueil du nouveau site: c'est bien ça ?

Jean-Luc
 
Nouveau WRInaute
Merci pour ta réponse Jean-Luc.

En fait je veux que www.ancien.com/jp devienne www.nouveau.jp
Par contre que la page www.ancien.com/jp/produit.html soit redirigé vers www.nouveau.jp/produit.html
Et ainsi de suite

En fait c est uen réecriture d URL que je voudrais. Car mes pages sont bien contenu dans le dossier jp de www.ancien.com ( pour japonnais)
Et j ai acheter le nom de domain www.nouveau.jp. Et je voudrai que www.ancien.com/jp/produit.html soit réecri www.nouveau.jp/produit.html
ainsi que le reste des pages du site.

Pour cela jai fait
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ancien.com/jp/$ [NC]
RewriteRule ^(.*)$ http://www.nouveau.jp/ [QSA,L]
RewriteRule ^htm/product/mp/integrat/prod/prod.htm$   http://www.nouveau.com/htm/product/mp/integrat/prod/prod.php [QSA,L]
code]

Mais ca me fait une redirection en 302. Hors je veux une redirection en 301.
Alors j ai modifié et cela donne

[code]RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ancien.com/jp/$ [NC]
RewriteRule ^(.*)$ http://www.nouveau.jp/ [QSA,L,R=301]
RewriteRule ^htm/product/mp/integrat/prod/prod.htm$   http://www.nouveau.com/htm/product/mp/integrat/prod/prod.php [QSA,L, R=301]

Mais la par contre ca ne marche plus...

Je pensais qu en rajoutant R=301 que ma redirections e ferait en 301 mais il doit y avoir une erreur quelque part car ca ne marche plus.

Merci
 
Nouveau WRInaute
Ce n est pas un site comme free, ou online.

en fait c'est pas vraiment uen redirection mais juste une ré ecriture d url...
 
WRInaute accro
Tu ne peux pas faire une simple réécriture si tu changes de domaine (ou alors il faudrait que ton Apache serve de proxy).

Malgré ma réponse précédente, tu continues à comparer HTTP_HOST à autre chose qu'un nom d'hôte. Tu es libre évidemment. :wink:

J'essaierais ceci:
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ancien.com$ [NC]
RewriteRule ^jp/(.*)$ http://www.nouveau.jp/$1 [QSA,L,R=301]
$1 récupère la partie de l'URL après /jp/ pour faire une redirection 301, page par page.

Jean-Luc
 
Nouveau WRInaute
voilà mon htacess

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.technifor.com$ [NC]
RewriteRule ^jp/(.*)$ http://www.technifor.jp/$1 [QSA,L,R=301]
RewriteRule ^htm/product/laser/laser-accessories.htm$   http://www.technifor.jp/htm/product/laser/laser-accessories.php [QSA,L]
RewriteRule ^htm/product/laser/lasertop410.htm$   http://www.technifor.jp/htm/product/laser/lasertop.php [QSA,L]
RewriteRule ^htm/product/laser/td410.htm$   http://www.technifor.jp/htm/product/laser/td412.php [QSA,L]
RewriteRule ^htm/product/laser/tf410.htm$   http://www.technifor.jp/htm/product/laser/tf420.php [QSA,L]
RewriteRule ^htm/product/mp/etabli/etabli.htm$   http://www.technifor.jp/htm/product/mp/etabli/etabli.php [QSA,L]
RewriteRule ^htm/product/mp/etabli/xf500/xf500.htm$   http://www.technifor.jp/htm/product/mp/etabli/xf500.php [QSA,L]
RewriteRule ^htm/product/mp/etabli/cn202z/za322.htm$   http://www.technifor.jp/htm/product/mp/etabli/za322.php  [QSA,L]
RewriteRule ^htm/product/mp/etabli/cn202z/za322.htm$   http://www.technifor.jp/htm/product/mp/etabli/za322.php  [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn110p/cn110p.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn110p/cn110p.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn212cp/cn212cp.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn212cp/cn212cp.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn212dp/cn212dp.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn212dp/cn212dp.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn212sp/cn212sp.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn212sp/cn212sp.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn312cm/cn312cm.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn312cm/cn312cm.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn312dm/cn312dm.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn312dm/cn312dm.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/cn312sm/cn312sm.htm$   http://www.technifor.jp/htm/product/mp/integrat/cn312sm/cn312sm.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/xf510cp/xf510cp.htm$   http://www.technifor.jp/htm/product/mp/integrat/xf510cp/xf510cp.php [QSA,L]
RewriteRule ^htm/product/mp/integrat/integrat.htm$   http://www.technifor.jp/htm/product/mp/integrat/integrat.php [QSA,L]
RewriteRule ^htm/product/mp/portable/portable.htm$   http://www.technifor.jp/htm/product/mp/portable/portable.php  [QSA,L]
RewriteRule ^htm/product/mp/portable/cn212s/cn212s.htm$   http://www.technifor.jp/htm/product/mp/portable/cn212s/cn212s.php [QSA,L]
RewriteRule ^htm/product/mp/portable/m120/m120.htm$   http://www.technifor.jp/htm/product/mp/portable/m120/m120.php  [QSA,L]
RewriteRule ^htm/product/mp/portable/xf520cp.htm$   http://www.technifor.jp/htm/product/mp/portable/xf520cp.php  [QSA,L]
RewriteRule ^htm/product/mp/tag/PFD101.htm$   http://www.technifor.jp/htm/product/mp/tag/pfd500.php [QSA,L]
RewriteRule ^htm/product/scribing/cn312sr/cn312cr.htm$   http://www.technifor.jp/htm/product/scribing/cn312cr.php  [QSA,L]
RewriteRule ^htm/product/scribing/cn312sr/cn312sr.htm$   http://www.technifor.jp/htm/product/scribing/cn312sr.php  [QSA,L]
RewriteRule ^htm/product/scribing/cn312sr/sv312.htm$   http://www.technifor.jp/htm/product/scribing/sv312.php [QSA,L]
RewriteRule ^htm/product/scribing/cn312sr/uc112.htm$   http://www.technifor.jp/htm/product/scribing/uc112.php [QSA,L]
ErrorDocument 404 http://www.technifor.jp/error.htm
ErrorDocument 301 http://www.technifor.jp/index.htm

Merci pour votre aide
 
WRInaute accro
Quel est le but de cette ligne ?
Code:
ErrorDocument 301 http://www.technifor.jp/index.htm
Pour moi, elle doit être supprimée.

Jean-Luc
 
Nouveau WRInaute
Pour moi le but de cette ligne est que quand l adresse est incorrecte que ca renvoie sur
Code:
http://www.technifor.jp/index.htm

Car sinon par defaut c etait renvoyé sur le .com
 
WRInaute accro
Quand l'adresse est incorrecte, c'est ErrorDocument 404 qui prend la main.

Je ne sais pas ce que fait Apache quand il voit ErrorDocument 301. Cette commande n'existe pas, mais elle pourrait quand même perturber tes redirections 301.

Qu'est-ce que ça donne quand tu supprimes cette ligne ?

Jean-Luc
 
Discussions similaires
Haut