Page 1 sur 2
url rewriting
Posté : 26 juin 2014, 21:44
par graffx
bonjour a tous,
je ne sais pas du tout dans quelle catégorie mettre ce sujet, il s'agit d' url rewriting avec des variables php.
Je vais au plus simple:
j' ai :
article.php?id=1&titre=2
Ca fonctionne avec ca:
RewriteRule ^article-([0-9]+)-(.*)$ article.php?id=$1&titre=$2 [L]
J'ai donc bien:
monsite/article-1-Ouverture-de-Zeniax.com
Mais voila, j'ai rajouté une variable catégorie:
article.php?cat=1&id=1&titre=2
J'aimerai que cette categorie sois affichée un peu comme un dossier de ce genre (actu etant une rubrique "categorie":
monsite.com/actu/article-1-Ouverture-de-Zeniax.com
Je n' y arrive pas.
Quelq'un aurait la solution?
Bien cordialement.
Re: url rewriting
Posté : 26 juin 2014, 22:01
par Elie
Code : Tout sélectionner
RewriteRule ^([A-Za-z0-9_-]+)/article-([0-9]+)-(.*)$ article.php?cat=$1&id=$2&titre=$3 [L]
Je vois pas trop le soucis en fait

Re: url rewriting
Posté : 26 juin 2014, 22:57
par graffx
Merci de ton attention mais ca ne fonctionne pas, ca envoi vers une page inexistante.
Il me semble que j'ai testé un truc dans le meme genre que le tiens, mais pas totu à fait pareil.
A mon avis ton exemple est proche du bon résultat.
Re: url rewriting
Posté : 26 juin 2014, 23:01
par Elie
Rajoute ca au debut :
Code : Tout sélectionner
# Le serveur doit suivre les liens symboliques :
Options +FollowSymlinks
Re: url rewriting
Posté : 26 juin 2014, 23:24
par graffx
Deja fait mais c'est vrai je l'ai pas signalé:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/([A-Za-z0-9_-]+)/article-([0-9]+)-(.*)$ article.php?cat=$1&id=$2&titre=$3 [L]
Re: url rewriting
Posté : 27 juin 2014, 00:13
par Elie
C'est ton hebergeur qui t'impose le / apres le ^ ?
Quel est ton hebergeur ?
Re: url rewriti1721ng
Posté : 27 juin 2014, 01:18
par graffx732
non non y'en a pas besoin je suis chez ovh j'ai libre accés a tout et tout est activé dans le php.ini, enfin ce qu'il faut.
Re: url rewriting
Posté : 27 juin 2014, 10:51
par moogli
salut,
le masque semble correct (tu peux tester sur un site comme
https://www.debuggex.com/).
est ce que tu as des erreurs dans le log httpd ?
est ce que tu test sur ton poste de dev ? (ajoute un vhost ainsi que l'entrée correspondante dans le fichier host de ta machine pour simuler exactement le même comportement).
@+
Re: url rewriti1721ng
Posté : 27 juin 2014, 11:06
par Sékiltoyai
non non y'en a pas besoin je suis chez ovh j'ai libre accés a tout et tout est activé dans le php.ini, enfin ce qu'il faut.
1/ Tu fais ton rewriting dans la conf serveur ou bien dans un .htaccess ?
2/ Essaye avec et sans le slash (la chaine à matcher peut changer en fonction du contexte de réécriture).
3/ Vérifie tes logs serveurs.
Re: url rewriting
Posté : 27 juin 2014, 19:28
par graffx
Alors je vais essayer de repondre a toute vos questions:
- j'ai rien compris a debuggex c'est un truc de fou.
- je fais mon rewriting dans le htaccess
- avec et sans slash mene vers un 404
- je me log pas sur un post de dev, j'envoi a chaque fois mon htaccess sur le serveur pour eviter des erreurs entre deux posts
- je ne sais comment et où voir les erreurs logs en general
Merci de votre aide!
Re: url rewriting
Posté : 27 juin 2014, 19:30
par graffx
Ha si j'ai pu trouver le log httpd mais je n'ai que ce genre de chose a repetition:
Code : Tout sélectionner
localhost - - [26/Jun/2014:03:10:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 371
localhost - - [26/Jun/2014:03:10:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 394
localhost - - [26/Jun/2014:03:10:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 394
localhost - - [26/Jun/2014:03:10:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 406
localhost - - [26/Jun/2014:03:10:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 402
localhost - - [26/Jun/2014:03:10:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 403
localhost - - [26/Jun/2014:03:11:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 399
localhost - - [26/Jun/2014:03:11:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 406
localhost - - [26/Jun/2014:03:11:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 402
localhost - - [26/Jun/2014:03:11:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 406
localhost - - [26/Jun/2014:03:11:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 406
localhost - - [26/Jun/2014:03:11:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 408
localhost - - [26/Jun/2014:03:12:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 408
localhost - - [26/Jun/2014:03:12:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 407
localhost - - [26/Jun/2014:03:12:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 408
localhost - - [26/Jun/2014:03:12:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 408
localhost - - [26/Jun/2014:03:12:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 403
localhost - - [26/Jun/2014:03:12:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:13:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:13:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:13:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:13:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 423
localhost - - [26/Jun/2014:03:13:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:13:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:14:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:14:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:14:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:14:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 425
localhost - - [26/Jun/2014:03:14:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:14:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:15:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:15:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 424
localhost - - [26/Jun/2014:03:15:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:15:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:15:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:15:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:16:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:16:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:16:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:16:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:16:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 424
localhost - - [26/Jun/2014:03:16:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 424
localhost - - [26/Jun/2014:03:17:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:17:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:17:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:17:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:17:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:17:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:18:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:18:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 425
localhost - - [26/Jun/2014:03:18:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:18:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:18:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:18:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:19:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:19:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:19:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:19:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:19:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:19:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:20:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:20:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:20:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:20:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 423
localhost - - [26/Jun/2014:03:20:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:20:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:21:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:21:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:21:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:21:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:21:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:21:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 422
localhost - - [26/Jun/2014:03:22:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:22:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:22:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:22:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 425
localhost - - [26/Jun/2014:03:22:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:22:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:23:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:23:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 424
localhost - - [26/Jun/2014:03:23:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:23:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:23:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:23:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:24:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:24:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:24:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:24:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:24:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:24:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:25:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:25:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:25:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:25:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:25:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:25:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:26:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:26:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:26:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:26:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 426
localhost - - [26/Jun/2014:03:26:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 428
localhost - - [26/Jun/2014:03:26:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:27:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 424
localhost - - [26/Jun/2014:03:27:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 428
localhost - - [26/Jun/2014:03:27:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:27:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 428
localhost - - [26/Jun/2014:03:27:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:27:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:28:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:28:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 428
localhost - - [26/Jun/2014:03:28:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:28:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:28:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:28:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:29:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:29:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:29:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:29:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:29:47 +0200] "GET /ovh-status?auto HTTP/1.1" 200 427
localhost - - [26/Jun/2014:03:29:57 +0200] "GET /ovh-status?auto HTTP/1.1" 200 429
localhost - - [26/Jun/2014:03:30:07 +0200] "GET /ovh-status?auto HTTP/1.1" 200 430
localhost - - [26/Jun/2014:03:30:17 +0200] "GET /ovh-status?auto HTTP/1.1" 200 430
localhost - - [26/Jun/2014:03:30:27 +0200] "GET /ovh-status?auto HTTP/1.1" 200 430
localhost - - [26/Jun/2014:03:30:37 +0200] "GET /ovh-status?auto HTTP/1.1" 200 430
localhost - - [26/Jun/2014:03:30:47 +0200]
Re: url rewriting
Posté : 27 juin 2014, 19:44
par Sékiltoyai
Ha si j'ai pu trouver le log httpd mais je n'ai que ce genre de chose a repetition:
Ça veut dire que tu n'as pas cherché assez longtemps.
Tu n'as rien d'autre dans /var/log/apache2/ ? Rien dans /chemin/vers/ton/site/logs/ ?
On ne pourra pas trouver les logs à ta place, c'est spécifique à l'hébergeur/OS.
Re: url rewriting
Posté : 27 juin 2014, 20:15
par graffx
Pas de soucis ms'ieur, je pense que c'était les indices qui me manquait, je cherche et vous redis ca, ca doit pas être facile le metier d'administrateur réseau lol!
Re: url rewriting
Posté : 27 juin 2014, 20:42
par graffx
dans home/log/httpd j'ai bien un monsite_access_log ou il y a plusieurs fois le lien de ma page:
26/Jun/2014:19:04:03 +0200] "GET /zeniax/actu/article-1-Ouverture-de-xxxxxx.com HTTP/1.1" 404 350 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0"
j'ai pas de dossier apache 2 dans var/log.
Mais en fait je sais pas trop ce que je dosi chercher et a quoi ca peut ressembler

Re: url rewriting
Posté : 27 juin 2014, 21:34
par graffx
Bon ben voila que maintenant ca fonctionne avec ta synthaxe, je n'y comprend plus rien.
Je peux en déduire que le sujet est résolu. Merci à tous pour votre aide, comme d'habitude, vous êtes geniaux.
A bientot!