I now have a need for SEO optimization. The code uses the Yii framework. Now I need to change some of the original long links into short links. I have two ideas for this. One is to make a 301 jump in PHP. One is to do 301 in the nginx configuration file. The problem is: I can’t match it in the nginx configuration file location? For example, the original link is xxx.bbb.ccc/index.php?r=pc/index/index, and now Using xxx.bbb.ccc/index, how can I match this?
According to you, shouldn’t it be accessing
xxx.bbb.ccc/index
->xxx.bbb.ccc/index.php?r=pc/index/index
?In this case, there is no need to match
?
.Just write
rewrite
the rulesIf it is reverse, use
if
to judge itFor example:
Test results: