This one is hard and heavy

New to mod_rewrite? This is a good place to start.

This one is hard and heavy

Postby daedralord » Thu Oct 22, 2009 3:58 pm

This one i find really hard.
RewriteRule ^Retete/$ /retete.php
RewriteRule ^Retete/(.*)/$ /retete_disp.php?cat=$1
RewriteRule ^Retete/(.*)/(.*)/$ /retete_disp2.php?id=$2&cat=$1

The first 2 rules work
when i type mydomain.com/Retete/ it goes to ->retete.php
when i type mydomain.com/Retete/category/ -> retete_disp.php?cat=category

but when i try
mydomain.com/Retete/category/2/ it does not access the file retete_disp2.php?id=2&cat=category instead id goes to
mydomain.com/Retete/category/2/retete.php

However if i change the last rule to
RewriteRule ^Retete->/(.*)/(.*)/$ /retete_disp2.php?id=$2&cat=$1
and access mydomain.com/Retete->/category/2/ it works fine. I really don't understand how this goes. Please help me.
daedralord
 
Posts: 2
Joined: Thu Oct 22, 2009 3:51 pm

Postby daedralord » Fri Oct 23, 2009 3:29 am

Well it seems that i solved the problem by learning some regexp :"> . Anyway if other people will have the same problem this is how i solved it:

RewriteRule ^Retete/$ /retete.php
RewriteRule ^Retete/([a-zA-z]+)/$ /retete_disp.php?cat=$1
RewriteRule ^Retete/([a-zA-z]+)/([0-9]+)/$ /retete_disp2.php?id=$2&cat=$1
daedralord
 
Posts: 2
Joined: Thu Oct 22, 2009 3:51 pm

Postby richardk » Fri Oct 23, 2009 9:17 am

Well it seems that i solved the problem by learning some regexp :"> .

Character classes

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^Retete/$ /retete.php [QSA,L]
RewriteRule ^Retete/([a-zA-Z]+)/$ /retete_disp.php?cat=$1 [QSA,L]
RewriteRule ^Retete/([a-zA-Z]+)/([0-9]+)/$ /retete_disp2.php?cat=$1&id=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 28 guests

cron