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
}