invader-u
dimanche 26 mars 2006 à 18:34
Je vais essayer de prendre un exemple plus clair :
Je veux rediriger ces 2 regles en y ajoutant une variable.
CODE
http://www.webmaster-hub.com/index.php?showtopic=22954
http://www.webmaster-hub.com/index.php?showtopic=22954&st=90
Comme cela
CODE
http://www.webmaster-hub.com/index.php?showtopic=22954&varajoutee=val
http://www.webmaster-hub.com/index.php?showtopic=22954&st=90&varajoutee=val
Mais par contre je veux pas que ca ajoute cette nouvelle variable si elle est deja ajoutee ou si l'url contient d'autres variables.
Dans mon exemple, je veux pas que ca ajoute si l'url est de ce type :
CODE
http://www.webmaster-hub.com/index.php?showtopic=22954&view=getlastpost
http://www.webmaster-hub.com/index.php?showtopic=22954&pid=457390&st=300&#entry457390 (normalement identique a la suivantecar l'ancre n'est pas transmise)
http://www.webmaster-hub.com/index.php?showtopic=22954&pid=457390&st=300&
http://www.webmaster-hub.com/index.php?showtopic=22954&view=getnewpost
http://www.webmaster-hub.com/index.php?showtopic=22954&hl=blouclage
http://www.webmaster-hub.com/index.php?showtopic=22954&varajoutee=val
http://www.webmaster-hub.com/index.php?showtopic=22954&st=90&varajoutee=val
Je peux faire comme tu dis mais je me demande si il y a pas plus simple et en plus si j'oublie une variable a exclure ca sera pas top :
CODE
RewriteCond %{QUERY_STRING} !view
RewriteCond %{QUERY_STRING} !pid
RewriteCond %{QUERY_STRING} !hl
RewriteCond %{QUERY_STRING} !varajoutee
RewriteCond %{QUERY_STRING} showtopic
RewriteRule index\.php index.php?varajoutee=val[QSA,L]
Merci par avance pour vos conseils
EDITION 1
En plus ca ne semble pas fonctionne.
J'ai mis ca comme regle dans le .htaccess de mon repertoire forum :
CODE
RewriteCond %{QUERY_STRING} !gopid
RewriteCond %{QUERY_STRING} !showforum
RewriteCond %{QUERY_STRING} !view
RewriteCond %{QUERY_STRING} !pid
RewriteCond %{QUERY_STRING} !hl
RewriteCond %{QUERY_STRING} !varajoutee
RewriteCond %{QUERY_STRING} showtopic
RewriteRule index\.php index.php?rfurl=original[QSA,L]
et dans le fichier inddex.php, j'ecris des traces dans un fichier :
ce qui me donne :
CODE
showtopic --> 4110
hl --> texterecherche
request_method --> get
URL entree : /forum/index.php?showtopic=4110&hl=texterecherche
aussi
_low_act -->
act --> st
furlindex -->
t --> 4110
f --> 3
alors que sur une de mes autres regles simple de redirection, j'ai comme trace :
CODE
showforum --> 19
rfurl --> new
URL entree : /forum/messages-conserver,f19.htm
aussi
request_method --> get
_low_act -->
act --> sf
furlindex --> 1
f --> 19
EDITION n2 :CODE
RewriteRule ^([-a-z0-9\.]*),t([0-9]*).htm index.php?showtopic=$2&titlefriendly=$1&rfurl=new [L,QSA]
Cette regle qui est placee au debut du .htaccess redirige vers la page d'acceuil du forum si j'ai aussi cette regle (en fin de fichier)
CODE
RewriteCond %{QUERY_STRING} !gopid
RewriteCond %{QUERY_STRING} !showforum
RewriteCond %{QUERY_STRING} !view
RewriteCond %{QUERY_STRING} !pid
RewriteCond %{QUERY_STRING} !hl
RewriteCond %{QUERY_STRING} !varajoutee
RewriteCond %{QUERY_STRING} showtopic
RewriteRule index\.php index.php?rfurl=original[QSA,L]
Si je commente la grosse regle ci dessus, la regle precedente fonctionne bien