nginx重写文件夹的重定向 [英] nginx rewrite redirect for a folder

查看:205
本文介绍了nginx重写文件夹的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部...

我正在尝试在nginx中执行一些操作,以重定向对

I am trying to do something in nginx to redirect all calls for files in

/images/

进入:

/assets/images/

有人可以帮助我制定重写规则吗?赋予301已永久移动的状态?

can someone help me with the rewrite rule? giving a 301 moved permanently status?

推荐答案

以下是使用较新版本的Nginx的首选方法:

Here's the preferred way to do this with newer versions of Nginx:

location ~ ^/images/(.*) {
    return 301 /assets/images/$1;
}

请参见 https://www.nginx.com/blog/creating-nginx-rewrite-rules /了解更多信息.

这篇关于nginx重写文件夹的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆