我正在使用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.
}
}
}