Score:0

Uppercase to lowercase in nginx module

hm flag

I have a nginx module which is redirecting the user to different folders depending on the URL. The logic is this: mysite.site/folder1, mysite.site/folder2, mysite.site/folder3 etc. What I want to do is to enforce that if the user writes mysite.site/Folder1 my server converts this to mysite.site/folder1 because otherwise the user is receiving 500 Internal Server Error. Any suggestion? this is my module:

server {

    listen 443 ssl;

    set $root_path '/var/www/mysite.site';
    root $root_path;

    index index.html index.htm index.nginx-debian.html index.php;

    server_name mysite.site www.mysite.site;

    location /folder1{

      alias /var/www/mysite.site/folder1;
      location ~ \.php$ {
           fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
      }
    }
    location /folder2{

      alias /var/www/mysite.site/folder2;
      location ~ \.php$ {
           fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
      }
    }
    location /folder3{

      alias /var/www/mysite.site/folder3;
      location ~ \.php$ {
           fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
      }
    }

    ssl_certificate /etc/letsencrypt/live/mysite.site/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.site/privkey.pem; # managed by Certbot

}

server {
    if ($host = www.mysite.site) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = mysite.site) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;

    server_name mysite.site www.mysite.site;
    return 404; # managed by Certbot

}
Nmath avatar
ng flag
This is not so much a question about Ubuntu as it is nginx - Does [this question on Stack Overflow](https://stackoverflow.com/q/18415508) answer your question?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.