Score:0

Nginx Server Block Always Prefix URL with String

us flag

In nginx server block I need to prefix url with country code always.

Example if request comes with example.com, I need it to redirect it to example.com/au Then I have a alias to handle /au location. But if it already comes as example.com/au I don't want this redirection to happen. Any help guys?

server {

    server_name  example.com;

    root   /data/www/public;
    index index.php index.html index.htm;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }



     location /au {
            alias /data/www/public;
            try_files $uri $uri/ @au;
            location ~ \.php$ {
                   include fastcgi_params;
                   fastcgi_param SCRIPT_FILENAME $request_filename;
                   fastcgi_param REQUEST_URI $request_uri;
                   fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }

    }

    location @au {
            rewrite /au/(.*)$ /au/index.php?/$1 last;
    }

    location ~ \.php$ {
    client_max_body_size 100M;
    proxy_connect_timeout           3600s;
    proxy_send_timeout              3600s;
    proxy_read_timeout          3600s;
    send_timeout                    3600s;
    fastcgi_read_timeout        300s;
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
            deny all;
    }

    location ~ /.well-known {
            allow all;
    }
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.