Page 1 of 1

rewrite rule problem

Posted: Sun Aug 30, 2009 4:31 am
by m2babaey
Hi
I use this rule:

Code: Select all

RewriteRule ^restaurants/([^/\.]+)/([^/\.]+)/([0-9]+)(.*)/ $ project/food/restaurentProfile.php?rid=$3
to redirect
domain.com/restaurants/state/city/12542-restaurant_name/
to
domain.com/restaurants.php?rid=12542

But I get 500 Internal Server Error
Where I am wrong?
Thank you for your help
Also tried this rule:

Code: Select all

RewriteRule ^restaurants/([^/\.]+)(.*)/([^/\.]+)(.*)/([0-9]+)(.*)/ $ restaurentProfile.php?rid=$5

Re: rewrite rule problem

Posted: Sun Aug 30, 2009 6:29 am
by mrvijayakumar
hi,

I hope problem is in /([^/\.]+)/([^/\.]+)/([0-9]+)(.*)/ $ this part. Try below code, It will works fine.

Code: Select all

RewriteRule ^restaurants/([^/]+)/ $ project/food/restaurentProfile.php?rid=$3

Re: rewrite rule problem

Posted: Sun Aug 30, 2009 8:20 am
by m2babaey
Thanks
I think space was a problem
This code is working now:

Code: Select all

RewriteRule ^restaurants/([^/.]+)/([^/.]+)/([0-9]+)(.*)$ project/food/restaurentProfile.php?rid=$3
Any security improvement suggestions?
This was my first rewrite rule

Re: rewrite rule problem

Posted: Sun Aug 30, 2009 8:00 pm
by m2babaey
Also how can i make it work vice versa
I mean redirect
domain.com/restaurants/state/city/restaurant_name-12542

to domain.com/restaurants.php?rid=12542

I tried this code but sends me a not found error:

Code: Select all

RewriteRule ^restaurants/([^/.]+)/([^/.]+)/([^/.-]+)-([0-9])$ project/food/restaurentProfile.php?rid=$4