Nginx redirect problem


#1

I think i have a problem. I don’t know where is but im looking for solutions. I have wordpress+nginx+pagespeed, i moved the folder uploads in root and changed with the name "cache". i used this command in wp-config: <code>define( 'UPLOADS', ''.'cache' );</code> after this i've added a subdomain for my site img.stancristina.com and it redirects to cache folder. cache.stancristina.com and stancristina.com/cache are working, but i want that my files to be visible only with cache.stancristina.com, not stancristina.com/cache. When i try to make a new article and to upload a file, that file is set primary stancristina.com/cache, not cache.stancristina.com as i wanted. What im wrong?
This is my conf:

server {  
listen 80;  
server_name stancristina.com www.stancristina.com;  
     location / {  
                try_files $uri $uri/ =404;        
    }  
root /srv/stancristina.com;  
 index index.php index.html index.htm;  

	if (!-e $request_filename) {  
	rewrite ^(.*)$ /index.php?q=$1 last;  
	rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;  
	rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;  
	break;  
	}  

       location ~ \.php$ {  
            fastcgi_buffers 8 256k;  
            fastcgi_buffer_size 128k;  
            fastcgi_intercept_errors off;  
            include fastcgi_params;  
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
            fastcgi_pass unix:/dev/shm/php-fpm-www.sock;  

        }  
	  
	location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }  
	location ~ "^/ngx_pagespeed_static/" { }  
	location ~ "^/ngx_pagespeed_beacon$" { }  
	location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }  
	location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }  
	location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }  
	location /pagespeed_console { allow 127.0.0.1; deny all; }  
}  

#Sub Domain  
server {  
listen 80;  
server_name cache.stancristina.com;  
autoindex off;  
location / {  
root /srv/stancristina.com/cache;  
}  
}

#2

I am sorry but we haven’t used pagespeed successfully in any production setup yet so I won’t be able to guide on this.

For CSS/JS minify we use w3-total-cache as of now.


#3

After reading again, I think you need to use CDN feature of “w3 total cache”, if you only want to rewrite file upload URL’s to another subdomain.


#4