views:

32

answers:

2

Hi, I am trying to redirect my pages using URL:

RewriteRule ^(.*)/content/(.*)/?(.*)\.html$ browse.php?s=$1&c=$2&l=$3 [NC,L]

For 2 parameters it works fine but when I passes 3 parameters it merges the 2 and third.

Correct output is as follow (2) parameters:

Array ( [s] => wallpapers [c] => Global_Celebrities [l] => Nicole1);

Merged messed output is here (3) parameters:

Array ( [s] => wallpapers [c] => Global_Celebrities/Kate1 [l] =>);

Thanks in advance.

+1  A: 

You need to use a more specific pattern. Try [^/]+ instead of .*:

RewriteRule ^([^/]+)/content/([^/]+)\.html$ browse.php?s=$1&c=$2 [NC,L]
RewriteRule ^([^/]+)/content/([^/]+)/([^/]+)\.html$ browse.php?s=$1&c=$2&l=$3 [NC,L]
Gumbo
Thanks for the prompt reply it works fine..
Thank you guyz you are the life Savior (K) ;)
+1  A: 

Easiest way is to go with 2 rules:

RewriteRule ^(.*)/content/(\w*)\.html$ browse.php?s=$1&c=$2 [NC,L]<br/>
RewriteRule ^(.*)/content/(\w*)/(\w*)\.html$ browse.php?s=$1&c=$2&l=$3 [NC,L]

Note, that I am using "\w" instead of ".", so that "." would be unable to eat "/". It might work with . too, it's just safer with \w.

BarsMonster