最近,我发现一些网站正在链接许多没有现存的url(缺少.html)到我的域。我将通过将所有404错误的urls指向正确的urls来降低爬行错误。
但是我很难在nginx中重定向301。
我想将domain.com/mp3/search重定向到domain.com/mp3/search.html
我的当前配置是:
location / {
rewrite ^/mp3/([^/]*).html(/?)+$ /index.php?mp3=$1;
#rewrite ^/mp3/([^/]*).html(/?)+$ /index.php?mp3=$1;
#rewrite ^/mp3/([^/]*)$ /$1.html;
}我试过了
#rewrite ^/mp3/([^/]*).html(/?)+$ /index.php?mp3=$1;它只是创建了domain.com/mp3/搜索页面
#rewrite ^/mp3/([^/]*)$ /$1.html;返回404
更多的例子:
mp3/Rank_1_&_Dennis_Sheperd to become mp3/Rank_1_&_Dennis_Sheperd.html
mp3/Flashlight_ to become mp3/Flashlight_.html
mp3/Let_her_go_ to become mp3/Let_her_go_.html
mp3/Audien_-_Iris to become mp3/Audien_-_Iris.html都有301重定向
发布于 2014-04-01 13:01:59
我觉得你要找的重写规则是:
rewrite ^/mp3/([^/]*)(?!.html)$ /mp3/$1.html permanent;https://stackoverflow.com/questions/22780014
复制相似问题