[resolu] ma regle ne match pas

WRInaute passionné
j'ai decidé d'utiliser le rewrite sur mon prochain site mais j'ai un problème avec RewriteRule,

dans le cas présent je veux juste rediriger les fr.domaine vers domaine/fr

Code:
RewriteEngine on 
#RewriteBase /
RewriteCond %{HTTP_HOST} !^drague.opendmoz.info$ [NC] 
RewriteCond %{HTTP_HOST} ^([a-z]*)\.drague\.opendmoz\.info$ [NC] 
RewriteRule ^([a-z]*)\.drague\.opendmoz\.info$ /$1/index.php

le log

Code:
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c2bb08/initial] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/ -> 
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c2bb08/initial] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri ''
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c2bb08/initial] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/index.html -> index.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'index.html'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/index.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/index.cgi -> index.cgi
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'index.cgi'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/index.cgi
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/index.pl -> index.pl
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'index.pl'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/index.pl
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/index.php -> index.php
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'index.php'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/index.php
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/index.xhtml -> index.xhtml
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'index.xhtml'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/index.xhtml
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/HEADER.html -> HEADER.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'HEADER.html'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#c15ad8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/HEADER.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f48c8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/en/ -> en/
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f48c8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'en/'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f48c8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/en/
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/en/index.html -> en/index.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'en/index.html'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/en/index.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/en/index.cgi -> en/index.cgi
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'en/index.cgi'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/en/index.cgi
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/en/index.pl -> en/index.pl
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'en/index.pl'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/en/index.pl
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/en/index.php -> en/index.php
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'en/index.php'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/en/index.php
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] strip per-dir prefix: /home/dragueur/docs/README.html -> README.html
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (3) [perdir /home/dragueur/docs/] applying pattern '^([a-z]*)\.drague\.opendmoz\.info$' to uri 'README.html'
192.168.0.10 - - [16/Dec/2007:20:47:41 +0100] [en.drague.opendmoz.info/sid#6ad728][rid#7f08a8/subreq] (1) [perdir /home/dragueur/docs/] pass through /home/dragueur/docs/README.html

rog
 
WRInaute passionné
Il n'est pas possible de faire du rewritting sur un domaine différent. la seule chose possible c'est de faire une redirection 301.
Code:
RewriteEngine on
#RewriteBase /
RewriteCond %{HTTP_HOST} !^drague\.opendmoz\.info$ [NC]
RewriteCond %{HTTP_HOST} ^([a-z]*)\.drague\.opendmoz\.info$ [NC]
RewriteRule ^(.*)$ http://drague.opendmoz.info/%1/$1 [R=301,L]
 
WRInaute passionné
je te remercie webmasterlamogere ça marche, mais oulalala ce que c'est subtile

en fait drague.opendmoz.info est un sous domaine declaré en vhost donc apache le considère comme un domaine

j'ai bidouillé pour que *.drague.opendmoz.info pointe sur le vhost

et j'ai simplifié ta commande par

Code:
RewriteRule ^(.*)$ http://drague.opendmoz.info/%1/index.php

je pensais que la barre d'adresse IE conserverait l'url " fr.drague.opendmoz.info " parce que sinon je ne vois pas l'interêt de rewriter le sous domaine

hors :

Code:
add path info postfix: /home/dragueur/docs/fr/index.php -> /home/dragueur/docs/fr/index.php/index.php
strip per-dir prefix: /home/dragueur/docs/fr/index.php/index.php -> fr/index.php/index.php
applying pattern '^(.*)$' to uri 'fr/index.php/index.php'
RewriteCond: input='fr.drague.opendmoz.info' pattern='!^drague\.opendmoz\.info$' [NC] => matched
RewriteCond: input='fr.drague.opendmoz.info' pattern='^([a-z]*)\.drague\.opendmoz\.info$' [NC] => matched
rewrite 'fr/index.php/index.php' -> 'http://drague.opendmoz.info/fr/index.php'
implicitly forcing redirect (rc=302) with http://drague.opendmoz.info/fr/index.php
trying to replace prefix /home/dragueur/docs/ with /
escaping http://drague.opendmoz.info/fr/index.php for redirect
redirect to http://drague.opendmoz.info/fr/index.php?plm [REDIRECT/302]
strip per-dir prefix: /home/dragueur/docs/fr/index.php -> fr/index.php
applying pattern '^(.*)$' to uri 'fr/index.php'
RewriteCond: input='drague.opendmoz.info' pattern='!^drague\.opendmoz\.info$' [NC] => not-matched
pass through /home/dragueur/docs/fr/index.php

indique que mod_rewrite fais une redirection et cela implique même que l'url rewritée va passer elle aussi par rewritecond

on ne peux pas rewrité sans faire de redirection ?

rog
 
WRInaute passionné
edit :

ça a l'air de fonctionner convenablement, l'url affichée dans le navigateur garde bien en.drague.opendmoz.info, j'ai ajouté un test d'existence de dossier

maintenant je vais attaquer la query string

rog

Code:
RewriteEngine on 

RewriteBase /

RewriteCond %{HTTP_HOST} !^drague\.opendmoz\.info$ [NC] 
RewriteCond %{HTTP_HOST} ^([a-z]*)\.drague\.opendmoz\.info$ [NC] 
RewriteCond %{DOCUMENT_ROOT}/%1 -d

RewriteRule ^(.*)$ %1/index.php


log

Code:
strip per-dir prefix: /home/dragueur/docs/index -> index
applying pattern '^(.*)$' to uri 'index'
RewriteCond: input='br.drague.opendmoz.info' pattern='!^drague\.opendmoz\.info$' [NC] => matched
RewriteCond: input='br.drague.opendmoz.info' pattern='^([a-z]*)\.drague\.opendmoz\.info$' [NC] => matched
RewriteCond: input='/home/dragueur/docs/br' pattern='-d' => matched
rewrite 'index' -> 'br/index.php'
add per-dir prefix: br/index.php -> /home/dragueur/docs/br/index.php
trying to replace prefix /home/dragueur/docs/ with /
strip matching prefix: /home/dragueur/docs/br/index.php -> br/index.php
add subst prefix: br/index.php -> /br/index.php
internal redirect with /br/index.php [INTERNAL REDIRECT]
strip per-dir prefix: /home/dragueur/docs/br/index.php -> br/index.php
applying pattern '^(.*)$' to uri 'br/index.php'
RewriteCond: input='br.drague.opendmoz.info' pattern='!^drague\.opendmoz\.info$' [NC] => matched
RewriteCond: input='br.drague.opendmoz.info' pattern='^([a-z]*)\.drague\.opendmoz\.info$' [NC] => matched
RewriteCond: input='/home/dragueur/docs/br' pattern='-d' => matched
rewrite 'br/index.php' -> 'br/index.php'
add per-dir prefix: br/index.php -> /home/dragueur/docs/br/index.php
initial URL equal rewritten URL: /home/dragueur/docs/br/index.php [IGNORING REWRITE]
 
WRInaute passionné
@webmasterlamogere

je te remercie pour les précisions, là je galère correctement sur la suite

lol
 
Discussions similaires
Haut