加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何使Nginx使URL不区分大小写

发布时间:2020-12-13 21:28:54 所属栏目:Nginx 来源:网络整理
导读:我正在使用Nginx做一个简单的演示网站,而我只是配置Nginx: server { listen 80; server_name www.abc.com; location / { index index.html; root /home/www.abc.com/; }} 在我的www.abc.com文件夹中,我有子文件夹Sub,里面有index.html文件.所以当我尝试访问

我正在使用Nginx做一个简单的演示网站,而我只是配置Nginx:

server {
    listen          80;
    server_name     www.abc.com;

    location / {
        index           index.html;
        root            /home/www.abc.com/;
    }
}

在我的www.abc.com文件夹中,我有子文件夹Sub,里面有index.html文件.所以当我尝试访问www.abc.com/Sub/index.html,那么它工作正常.如果我访问www.abc.com/sub/index.html,它返回404.

如何在URL中配置Nginx不区分大小写?

最佳答案
server {
    # Default,you don't need this!
    #listen          80;

    server_name     www.abc.com;

    # Index and root are global configurations for the whole server.
    index           index.html;
    root            /home/www.abc.com/;

    location / {
        location ~* ^/sub/ {
            # The tilde and asterisks ensure that this location will
            # be matched case insensitive. nginx does not support
            # setting absolutely everything to be case insensitive.
            # The reason is easy,it's costly in terms of performance.
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读