How can I get around using alias in nginx?

Solution 1:

Rewrite the URI :

location /blog {

    root /var/www/mysite/wordpress;
    rewrite ^/blog/([^.]+\.[^.]+)$ /$1 break;
    try_files $uri $uri/ /blog/index.php$is_args$args;

    location ~ \.php {
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_split_path_info ^(?:\/blog\/)(.+\.php)(.*);
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }

}

This will remove the /blog part of the URI for URIs containing a potential file suffix in it (something.something).