Ordre des règles dans fichier htaccess

WRInaute discret
Salut !

Je cherche des explications concernant l'ordre des règles du fichier htaccess.

Ce dernier se trouve à la racine du site mais je dois en ajouter d'autres pour référencer mon forum (phpBB SEO mod Rewrite Intermédiaire)
Je ne sais donc pas si je dois les placer à la suite, ou entre d'autres déjà existantes.

Pour l'instant, il est constitué de cette façon :

En premier lieu :
Les règles "RedirectPermanent" (pour les pages dont l'url a changé)
Au nombre de 9.

Ensuite :

La règle permettant de forcer le "www"
RewriteEngine on
RewriteCond %{HTTP_HOST} ^otop-nutrition.fr [NC]
RewriteRule ^(.*) http://www.otop-nutrition.fr/$1 [QSA,R=301,L]

Ensuite cette liste pris sur wri :
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} Advanced\ Email\ Extractor [OR]
RewriteCond %{HTTP_USER_AGENT} almaden [NC,OR]
RewriteCond %{HTTP_USER_AGENT} @nonymouse [OR]
RewriteCond %{HTTP_USER_AGENT} Art-Online [OR]
RewriteCond %{HTTP_USER_AGENT} CherryPicker [OR]
RewriteCond %{HTTP_USER_AGENT} Crescent\ Internet\ ToolPack [OR]
RewriteCond %{HTTP_USER_AGENT} DirectUpdate [OR]
RewriteCond %{HTTP_USER_AGENT} Download\ Accelerator [OR]
RewriteCond %{HTTP_USER_AGENT} eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} echo\ extense [OR]
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR]
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} Fetch\ API\ Request [OR]
RewriteCond %{HTTP_USER_AGENT} flashget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} frontpage [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} HTTP\ agent [OR]
RewriteCond %{HTTP_USER_AGENT} HTTPConnect [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [OR]
RewriteCond %{HTTP_USER_AGENT} IPiumBot\ laurion(dot)com [OR]
RewriteCond %{HTTP_USER_AGENT} Kapere [OR]
RewriteCond %{HTTP_USER_AGENT} libwww-perl [OR]
RewriteCond %{HTTP_USER_AGENT} Microsoft\ URL\ Control [OR]
RewriteCond %{HTTP_USER_AGENT} minibot\(NaverRobot\) [OR]
RewriteCond %{HTTP_USER_AGENT} NICErsPRO [OR]
RewriteCond %{HTTP_USER_AGENT} NPBot [OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} Program\ Shareware [OR]
RewriteCond %{HTTP_USER_AGENT} QuepasaCreep [OR]
RewriteCond %{HTTP_USER_AGENT} SiteMapper [OR]
RewriteCond %{HTTP_USER_AGENT} Star\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} SurveyBot [OR]
RewriteCond %{HTTP_USER_AGENT} Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} Telesoft [OR]
RewriteCond %{HTTP_USER_AGENT} TuringOS [OR]
RewriteCond %{HTTP_USER_AGENT} TurnitinBot [OR]
RewriteCond %{HTTP_USER_AGENT} vobsub [NC,OR]
RewriteCond %{HTTP_USER_AGENT} webbandit [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebCapture [OR]
RewriteCond %{HTTP_USER_AGENT} webcollage [OR]
RewriteCond %{HTTP_USER_AGENT} WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} WebDAV [OR]
RewriteCond %{HTTP_USER_AGENT} WebEmailExtractor [OR]
RewriteCond %{HTTP_USER_AGENT} WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} WEBsaver [OR]
RewriteCond %{HTTP_USER_AGENT} WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} Wget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Wysigot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} Zeus [OR]
RewriteCond %{HTTP_REFERER} ^XXX
RewriteRule ^.*$ http://www.autre_site.com [R,L]
# Une redirection interne compte pour 2 hits
# Une redirection externe compte pour 1 hit


Votre avis ? Merci !
 
WRInaute passionné
il y a une règle très importante : les règles de réécriture sont testées par le serveur apache dans l'ordre. c'est la première qui correspond qui est prise. Il ne faut donc pas mettre en premier une règle générale comme par exemple :
Code:
RewriteRule ^(.*) http://www.otop-nutrition.fr/$1 [QSA,R=301,L]
 
WRInaute accro
de mon coté je dev mes .htaccess dans cet ordre

Les erreurs Documents (404, 500...) (gros pourcentage chez moi)
forcer le "www" ( relativement demander lors des visites naturelles)
les regles générales de réécritures (90% des demandes)
les RedirectPermanent (quelques pages en generales, puis se sont des regles mises temporairement)
test des HTTP_USER_AGENT (en dernier si le site est tres peu aspirer et hacker)
 
WRInaute impliqué
KOogar a dit:
de mon coté je dev mes .htaccess dans cet ordre

Les erreurs Documents (404, 500...) (gros pourcentage chez moi)
forcer le "www" ( relativement demander lors des visites naturelles)
les règles générales de réécritures (90% des demandes)
les RedirectPermanent (quelques pages en générales, puis se sont des règles mises temporairement)
test des HTTP_USER_AGENT (en dernier si le site est très peu aspirer et hacker)

Koogar pourquoi :
4° les RedirectPermanent (quelques pages en générales, puis se sont des regles mises temporairement)

Elles doivent être mises temporairement jusqu'à ce que le GG BOBOT réindex après vous enlevez le redirect ?
 
WRInaute accro
Oui c'est ca. Cela prend entre quelques heures et quelques jours.
Mais il faut egalement voir si la page a des visites naturelles, genre des intenautes qui l'on placée dans leur favoris. Dans ce cas il faut peut-etre laisser cette redirection permanente plus longtemps.
 
WRInaute discret
Le problème est que lorsque j'inclus dans mon htaccess des règles relatives à mon forum, impossible d'accéder à certaines pages de mon site.

J'ai mis du temps à m'apercevoir qu'il s'agissait du fichier htaccess....

J'ai essayé de modifier l'ordre et de faire plusieurs essais mais en vain

Voici le contenu de mon fichier :


ErrorDocument 404 /erreur404.php

RedirectPermanent /complements-alimentaires/vitamines.html http://www.otop-nutrition.fr/complement ... works.html
RedirectPermanent /complements-alimentaires/fibres.html http://www.otop-nutrition.fr/complement ... works.html
RedirectPermanent /soin-du-corps/index.html http://www.otop-nutrition.fr/soin-du-corps.html
RedirectPermanent /soin-des-cheveux/index.html http://www.otop-nutrition.fr/soin-des-cheveux.html
RedirectPermanent /soin-du-visage/nourifusion.html http://www.otop-nutrition.fr/soin-du-visage.html
RedirectPermanent /soin-du-visage/shapeworks.html http://www.otop-nutrition.fr/gestion-de ... works.html
RedirectPermanent /soin-du-visage/barres-proteines.html http://www.otop-nutrition.fr/gestion-de ... eines.html
RedirectPermanent /soin-du-visage/formule3.html http://www.otop-nutrition.fr/gestion-de ... mule3.html
RedirectPermanent /soin-du-visage/formule1.html http://www.otop-nutrition.fr/gestion-de ... mule1.html
RedirectPermanent /soin-du-visage/graines-soja.html http://www.otop-nutrition.fr/gestion-de ... -soja.html
RedirectPermanent /soin-du-visage/boisson-proteines.html http://www.otop-nutrition.fr/gestion-de ... eines.html
RedirectPermanent /soin-du-visage/anti-age.html http://www.otop-nutrition.fr/skin-activ ... i-age.html

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.otop-nutrition\.fr [NC]
RewriteRule (.*) http://www.otop-nutrition.fr/$1 [QSA,R=301,L]

RewriteRule ^forum/.+/([^/]+\.html)$ /forum/$1 [R=301,L]
RewriteRule [.]*-vf([0-9]*) /forum/viewforum.php?%{QUERY_STRING}&f=$1
RewriteRule [.]*-vp([0-9]*) /forum/viewtopic.php?%{QUERY_STRING}&p=$1
RewriteRule [.]*-vt([0-9]*) /forum/viewtopic.php?%{QUERY_STRING}&t=$1
RewriteRule [.]*-vc([0-9]*) /forum/index.php?%{QUERY_STRING}&c=$1
RewriteRule [.]*-ac([0-9]*) /forum/album_cat.php?%{QUERY_STRING}&cat_id=$1
RewriteRule [.]*-at([0-9]*) /forum/album_thumbnail.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-apic([0-9]*) /forum/album_pic.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-apm([0-9]*) /forum/album_picm.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-full-asp([0-9]*) /forum/album_showpage.php?full=&pic_id=$1
RewriteRule [.]*-asp([0-9]*) /forum/album_showpage.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-aper([0-9]*) /forum/album_personal.php?%{QUERY_STRING}&user_id=$1
RewriteRule [.]*-dc([0-9]*) /forum/dload.php?%{QUERY_STRING}action=category&cat_id=$1
RewriteRule [.]*-df([0-9]*) /forum/dload.php?%{QUERY_STRING}action=file&file_id=$1
RewriteRule [.]*-kbc([0-9]*) /forum/kb.php?%{QUERY_STRING}mode=cat&cat=$1
RewriteRule [.]*-kba([0-9]*) /forum/kb.php?%{QUERY_STRING}mode=article&k=$1
RewriteRule [.]*-kbsmp /forum/kb.php?mode=stats&stats=mostpopular
RewriteRule [.]*-kbstr /forum/kb.php?mode=stats&stats=toprated
RewriteRule [.]*-kbsl /forum/kb.php?mode=stats&stats=latest
RewriteRule [.]*-pbc([0-9]*) /forum/kb.php?%{QUERY_STRING}mode=cat&cat=$1
RewriteRule [.]*-pa([0-9]*) /forum/kb.php?%{QUERY_STRING}mode=article&k=$1
RewriteRule [.]*-psmp /forum/kb.php?mode=stats&stats=mostpopular
RewriteRule [.]*-pstr /forum/kb.php?mode=stats&stats=toprated
RewriteRule [.]*-pbsl /forum/kb.php?mode=stats&stats=latest

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} Advanced\ Email\ Extractor [OR]
RewriteCond %{HTTP_USER_AGENT} almaden [NC,OR]
RewriteCond %{HTTP_USER_AGENT} @nonymouse [OR]
RewriteCond %{HTTP_USER_AGENT} Art-Online [OR]
RewriteCond %{HTTP_USER_AGENT} CherryPicker [OR]
RewriteCond %{HTTP_USER_AGENT} Crescent\ Internet\ ToolPack [OR]
RewriteCond %{HTTP_USER_AGENT} DirectUpdate [OR]
RewriteCond %{HTTP_USER_AGENT} Download\ Accelerator [OR]
RewriteCond %{HTTP_USER_AGENT} eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} echo\ extense [OR]
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR]
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} Fetch\ API\ Request [OR]
RewriteCond %{HTTP_USER_AGENT} flashget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} frontpage [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} HTTP\ agent [OR]
RewriteCond %{HTTP_USER_AGENT} HTTPConnect [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [OR]
RewriteCond %{HTTP_USER_AGENT} IPiumBot\ laurion(dot)com [OR]
RewriteCond %{HTTP_USER_AGENT} Kapere [OR]
RewriteCond %{HTTP_USER_AGENT} libwww-perl [OR]
RewriteCond %{HTTP_USER_AGENT} Microsoft\ URL\ Control [OR]
RewriteCond %{HTTP_USER_AGENT} minibot\(NaverRobot\) [OR]
RewriteCond %{HTTP_USER_AGENT} NICErsPRO [OR]
RewriteCond %{HTTP_USER_AGENT} NPBot [OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} Program\ Shareware [OR]
RewriteCond %{HTTP_USER_AGENT} QuepasaCreep [OR]
RewriteCond %{HTTP_USER_AGENT} SiteMapper [OR]
RewriteCond %{HTTP_USER_AGENT} Star\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} SurveyBot [OR]
RewriteCond %{HTTP_USER_AGENT} Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} Telesoft [OR]
RewriteCond %{HTTP_USER_AGENT} TuringOS [OR]
RewriteCond %{HTTP_USER_AGENT} TurnitinBot [OR]
RewriteCond %{HTTP_USER_AGENT} vobsub [NC,OR]
RewriteCond %{HTTP_USER_AGENT} webbandit [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebCapture [OR]
RewriteCond %{HTTP_USER_AGENT} webcollage [OR]
RewriteCond %{HTTP_USER_AGENT} WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} WebDAV [OR]
RewriteCond %{HTTP_USER_AGENT} WebEmailExtractor [OR]
RewriteCond %{HTTP_USER_AGENT} WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} WEBsaver [OR]
RewriteCond %{HTTP_USER_AGENT} WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} Wget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Wysigot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} Zeus [OR]
RewriteCond %{HTTP_REFERER} ^XXX
RewriteRule ^.*$ http://www.autre_site.com [R,L]
# Une redirection interne compte pour 2 hits
# Une redirection externe compte pour 1 hit

J'ai fait une erreur quelque part, mais ou ?

Cela viendrait-il du 2e RewriteEngine On ?

D'avance merci pour vos avis éclairés ;-)
 
WRInaute discret
L'erreur vient du code phpBB-google-keyword-URLs-2.3.1.txt

Quand je l'applique au niveau du htaccess et SEUL, ca ne fonctionne pas et m'indique :

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Voici ce code :

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#Pour que example.com soit changé en www.example.com sur tout votre site
RewriteCond %{HTTP_HOST} !^www.example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,R=301,L]

RewriteRule ^dossierphpbb/.+/([^/]+\.html)$ /dossierphpbb/$1 [R=301,L]
RewriteRule [.]*-vf([0-9]*) /dossierphpbb/viewforum.php?%{QUERY_STRING}&f=$1
RewriteRule [.]*-vp([0-9]*) /dossierphpbb/viewtopic.php?%{QUERY_STRING}&p=$1
RewriteRule [.]*-vt([0-9]*) /dossierphpbb/viewtopic.php?%{QUERY_STRING}&t=$1
RewriteRule [.]*-vc([0-9]*) /dossierphpbb/index.php?%{QUERY_STRING}&c=$1
RewriteRule [.]*-ac([0-9]*) /dossierphpbb/album_cat.php?%{QUERY_STRING}&cat_id=$1
RewriteRule [.]*-at([0-9]*) /dossierphpbb/album_thumbnail.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-apic([0-9]*) /dossierphpbb/album_pic.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-apm([0-9]*) /dossierphpbb/album_picm.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-full-asp([0-9]*) /dossierphpbb/album_showpage.php?full=&pic_id=$1
RewriteRule [.]*-asp([0-9]*) /dossierphpbb/album_showpage.php?%{QUERY_STRING}&pic_id=$1
RewriteRule [.]*-aper([0-9]*) /dossierphpbb/album_personal.php?%{QUERY_STRING}&user_id=$1
RewriteRule [.]*-dc([0-9]*) /dossierphpbb/dload.php?%{QUERY_STRING}action=category&cat_id=$1
RewriteRule [.]*-df([0-9]*) /dossierphpbb/dload.php?%{QUERY_STRING}action=file&file_id=$1
RewriteRule [.]*-kbc([0-9]*) /dossierphpbb/kb.php?%{QUERY_STRING}mode=cat&cat=$1
RewriteRule [.]*-kba([0-9]*) /dossierphpbb/kb.php?%{QUERY_STRING}mode=article&k=$1
RewriteRule [.]*-kbsmp /dossierphpbb/kb.php?mode=stats&stats=mostpopular
RewriteRule [.]*-kbstr /dossierphpbb/kb.php?mode=stats&stats=toprated
RewriteRule [.]*-kbsl /dossierphpbb/kb.php?mode=stats&stats=latest
RewriteRule [.]*-pbc([0-9]*) /dossierphpbb/kb.php?%{QUERY_STRING}mode=cat&cat=$1
RewriteRule [.]*-pa([0-9]*) /dossierphpbb/kb.php?%{QUERY_STRING}mode=article&k=$1
RewriteRule [.]*-psmp /dossierphpbb/kb.php?mode=stats&stats=mostpopular
RewriteRule [.]*-pstr /dossierphpbb/kb.php?mode=stats&stats=toprated
RewriteRule [.]*-pbsl /dossierphpbb/kb.php?mode=stats&stats=latest
 
Discussions similaires
Haut