2

I am using mod rewrite in an .htaccess file to change the URL to a nicer one, it converts this:

http://domain.com?a=test&v=page&id=3

to

http://domain.com/test/page/3

using this condition

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?a=$1&v=$2&id=$3 [L]

I want to do something different if $1 == cart and $2 == home

Here is some pseudo code for the idea using a php if condition

if($1 == 'cart' && $2 == 'home'){
   here I want to do a different rewrite rule
}else{
   RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?a=$1&v=$2&id=$3 [L]
}

Any idea as to how I go about that?

2 Answers 2

3

2 rewrite rules, with the predefined one first:

RewriteRule ^cart/home/([^/\.]+)?$            page2.php?id=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$  index.php?a=$1&v=$2&id=$3 [L]
0

Try this:

RewriteRule ^cart/home/([^/.]+)?$ other_page.php?id=$1 [L]

Then continue with the rule you already have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.