IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Apache Discussion :

Url rewriting et dossiers virtuels


Sujet :

Apache

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Février 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2011
    Messages : 37
    Points : 41
    Points
    41
    Par défaut Url rewriting et dossiers virtuels
    Bonjour à tous,

    Ca fait 2heures que je tourne en rond sur mon .htaccess et dans tout ce que j'ai pu trouver, rien n'y fait ... Le problème est simple, dans mon fichier, j'ai ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    RewriteEngine on 
    RewriteBase / 
    RewriteRule ^([a-z]+/)?([0-9a-zA-Z-]+)$ /index.php?id=$1&usr=$2 [L,NC]]
    exemple d'url : http://127.0.0.1/validation/3k8mklf113dklq29wn3iokld
    pour ma page : http://127.0.0.1/index.php?id=valida...dklq29wn3iokld

    Tout ce passe correctement sur le navigateur (!) mais dans le log apache j'ai ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    [Sat Feb 19 17:36:28 2011] [error] [client 127.0.0.1] File does not exist: I:/Web/validation, referer: http://127.0.0.1/validation/3k8mklf113dklq29wn3iokld
    Vous n'auriez pas une petite idée?

    Merci d'avance!

  2. #2
    Rédacteur
    Avatar de _Mac_
    Profil pro
    Inscrit en
    Août 2005
    Messages
    9 601
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2005
    Messages : 9 601
    Points : 12 977
    Points
    12 977
    Par défaut
    Difficile de dire où est le problème. Vue la trace d'erreur, le code HTML de http://127.0.0.1/validation/3k8mklf113dklq29wn3iokld contient une URL qu'Apache interprète (après ou sans réécriture, je ne sais pas) comme pointant sur la ressource système I:/Web/validation qui n'existe visiblement pas. A la limite, active les logs de mod_rewrite pour voir si le problème vient de la réécriture, mais il faut aussi examiner le code HTML de la page.

    Du détail, du détail, du détail !!!
    Revenons à la source : lisons la documentation et les fichiers de trace, la réponse à notre problème s'y trouve sans doute

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Février 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2011
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    Whaou!

    Merci pour la rapidité et la pertinence de ton intervention Je ne savais pas qu'il y avait des logs pour le mod rewrite, je vais voir ça alors... Sinon, effectivement le problème c'est que l'url est "virtuelle" et que par définition, l'arborescence n'existe pas. Mon code html est correct mais il me semble que ce qui se passe en fait, est que pour les images, par exemple, au lieu de suivre le css de l'index.php, Apache va changer le document_root de /web/gfx/ à /web/validation/gfx qui n'existe pas, tu me suis?

    En gros, le système est tel que le dossier root se présent comme suit :

    index.php (fichier)
    .htaccess (fichier
    gfx/ (dossier image)
    inc/ (dossier includes)
    cnt/ (dossier de contenu)

    [...]

    Dans index.php, un include s'effectue selon la variable "id" qui injecte la page demandée par l'utilisateur (en l'occurence "validation" qui se trouve dans le dossier cnt/validation.php), et à partir de cette include, l'url rewrite me pose problème car il va chercher de l'information (images, includes) là où n'existe pas.

    Enfin bref, dans un premier temps, je vais controler mes logs! Encore merci, je reviendrai poster plus tard xD

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Février 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2011
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    Ah oui! J'oubliais, pour être sûr que le problème ne vienne pas de l'html, dans mon index.php j'ai ajouter la ligne:

    $proper_id = str_replace('/', '', trim($_GET['id']));

    afin d'avoir un id pur texte!

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Février 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2011
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    Voilà le log rewrite en level 9, en warn, il n'affichait rien, je suppose qu'on peut descendre jusqu'à la ligne //le dossier saute! car c'est à partir de là qu'il cherche un dossier qui n'existe pas!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] add path info postfix: I:/Web/confirm -> I:/Web/confirm/26399a42a0511380c1cb111546baf0ca
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/confirm/26399a42a0511380c1cb111546baf0ca -> confirm/26399a42a0511380c1cb111546baf0ca
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] applying pattern '.*\.(png|swf|flv|mp3|mp4|jpe?g)$' to uri 'confirm/26399a42a0511380c1cb111546baf0ca'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] add path info postfix: I:/Web/confirm -> I:/Web/confirm/26399a42a0511380c1cb111546baf0ca
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/confirm/26399a42a0511380c1cb111546baf0ca -> confirm/26399a42a0511380c1cb111546baf0ca
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) [perdir I:/Web/] applying pattern '^([a-z]+/)?([0-9a-zA-Z-]+)$' to uri 'confirm/26399a42a0511380c1cb111546baf0ca'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/inc' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/inc/js' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/inc/lang' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/inc/pma' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/gfx' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/cnt' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/pma' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/usr' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/usr/pics' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (4) [perdir I:/Web/] RewriteCond: input='/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^/usr/vids' => matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (2) [perdir I:/Web/] rewrite 'confirm/26399a42a0511380c1cb111546baf0ca' -> '/index.php?id=confirm/&usr=26399a42a0511380c1cb111546baf0ca'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (3) split uri=/index.php?id=confirm/&usr=26399a42a0511380c1cb111546baf0ca -> uri=/index.php, args=id=confirm/&usr=26399a42a0511380c1cb111546baf0ca
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (2) [perdir I:/Web/] trying to replace prefix I:/Web/ with /
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#319f448/initial] (1) [perdir I:/Web/] internal redirect with /index.php [INTERNAL REDIRECT]
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/index.php -> index.php
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] applying pattern '.*\.(png|swf|flv|mp3|mp4|jpe?g)$' to uri 'index.php'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/index.php -> index.php
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] applying pattern '^([a-z]+/)?([0-9a-zA-Z-]+)$' to uri 'index.php'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/index.php -> index.php
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (3) [perdir I:/Web/] applying pattern '^([0-9a-zA-Z-]+)$' to uri 'index.php'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#31991f8/initial/redir#1] (1) [perdir I:/Web/] pass through I:/Web/index.php
    // le dossier saute!
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] add path info postfix: I:/Web/confirm -> I:/Web/confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/confirm/gfx/w.png -> confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] applying pattern '.*\.(png|swf|flv|mp3|mp4|jpe?g)$' to uri 'confirm/gfx/w.png'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (4) [perdir I:/Web/] RewriteCond: input='http://127.0.0.1/confirm/26399a42a0511380c1cb111546baf0ca' pattern='!^http://127.0.0.1/.*$' [NC] => not-matched
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] add path info postfix: I:/Web/confirm -> I:/Web/confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/confirm/gfx/w.png -> confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] applying pattern '^([a-z]+/)?([0-9a-zA-Z-]+)$' to uri 'confirm/gfx/w.png'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] add path info postfix: I:/Web/confirm -> I:/Web/confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] strip per-dir prefix: I:/Web/confirm/gfx/w.png -> confirm/gfx/w.png
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (3) [perdir I:/Web/] applying pattern '^([0-9a-zA-Z-]+)$' to uri 'confirm/gfx/w.png'
    127.0.0.1 - - [19/Feb/2011:18:47:57 +0100] [127.0.0.1/sid#1515150][rid#30aa300/initial] (1) [perdir I:/Web/] pass through I:/Web/confirm
    C'est quoi le prob avec le postfix?

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Février 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2011
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    Tout compte fait, le .css est correct... Mais les images en pur html <img src="gfx/w.png"> ne s'affichent pas (désolé mais ce sont des images cachées au chargement de la page donc je ne les avais pas vu!)... Bizarre... Je vais voir ça.

    Edit: effectivement... j'ai toutes mes adresses en url absolues et j'ai mis du relatif pour 3 images lol... d'où le problème! Merci pour ton intervention mac! J'ai pu cibler le souci grace aux logs

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. URL rewriting et repertoire virtuel
    Par morgbl dans le forum Apache
    Réponses: 5
    Dernier message: 16/11/2008, 01h56
  2. url rewrite et répertoire virtuel
    Par johnass dans le forum Apache
    Réponses: 1
    Dernier message: 11/08/2008, 00h50
  3. Réponses: 2
    Dernier message: 16/04/2008, 15h27
  4. [URL Rewriting] Sous-domaines virtuels ?
    Par Ikonic dans le forum Apache
    Réponses: 2
    Dernier message: 10/04/2008, 11h42
  5. [URL Rewriting] Redirection dossier vers lien
    Par alikharchafi dans le forum Apache
    Réponses: 13
    Dernier message: 16/10/2007, 14h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo