views:

62

answers:

1

Someone please tell me what is wrong with this htaccess rules?

 RewriteCond %{QUERY_STRING} ^q=(.*)&type=downway1$ [NC]
 RewriteRule ^search\.php$  /search\/%1\/1\/? [R=301,NC,L]

 RewriteCond %{QUERY_STRING} ^q=(.*)&type=(.*)$ [NC]
 RewriteRule ^search\.php$  /search\/%1\/%2\/1\/? [R=301,NC,L]

 RewriteRule search/(.*)/(.*)/$  /search.php?q=$1&page=$2 [L] <-- this and
 RewriteRule search/(.*)/(.*)/(.*)/$  /search.php?q=$1&type=$2&page=$3 [L] <-- this 

are not working in same time. for example TYPE = app Q = windows

if I search type by downway1 it works powerfully but if I search in app type Q becomes windows/app not only windows. help me please!

edit: im trying to redirect "search.php?q=someterm&page=1" to "/search/someterm/1/" and "search.php?q=someterm&type=sometype&page=1" to "/search/sometype/someterm/1/"

+1  A: 

Rewrite rules are applied in order. In this case, /search/(.*)/(.*)/$ is tested first, and actually does match /search/windows/app/1/, because the dot operator matches everything, including forward slashes.

Try switching the order of the rules, or, even better, make them order independent by changing (.*) to ([^/]*), which means match everything, except forward slashes. This will make the first test fail for /search/windows/app/1/, so apache will move on to the second.

kibibu
I'm getting "Attempting to open is not going to end any time entered into a routing loop." error. :((
Ronnie Chester Lynwood