Aman Singh
Aman Singh

Reputation: 753

Rewriting url in apache is not working

I am using the following code in .htaccess direct editor in ipage server for changing my website's page url from

for example:

http://foodinger.in/viewRestaurant.php?raipur=Barbecue-Country&id=3006

to

http://foodinger.in/viewRestaurant/raipur/Barbecue-Country

but it is not working

RewriteEngine on

RewriteRule viewRestaurant/raipur/(.*)/ viewRestaurant.php?raipur=$1&id=$2

RewriteRule viewRestaurant/raipur/(.*) viewRestaurant.php?raipur=$1&id=$2

Am i doing anything wrong, Please anyone suggest me the right way if i am wrong ? Thanks in advance

Upvotes: 0

Views: 41

Answers (1)

rutsky
rutsky

Reputation: 4110

You specify only one group for substitution (.*) that will replace $1 in target url.

Try:

RewriteEngine on

RewriteRule "^/viewRestaurant/raipur/(.*)/(.*)/?" "/viewRestaurant.php?raipur=$1&id=$2"

And query with Id: http://foodinger.in/viewRestaurant/raipur/Barbecue-Country/3006

Upvotes: 1

Related Questions