开发者

What Am I Doing Wrong on this HTACCESS file?

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/"


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜