T
T
teet2014-03-31 10:19:18
Nginx
teet, 2014-03-31 10:19:18

How to redirect a specific nginx file?

Good afternoon.
There is an application: the client is written in actionScript, the server is in php (we use the symfony framework).
Since the application has become popular, loading the client side has begun to load our network. We decided to transfer the files of the client part of the application to another server (the bandwidth is larger there and the traffic per month is practically unlimited). To redirect requests to another server, I changed the nginx settings:

rewrite ^/app\.php/?(.*)$ /$1 permanent;

location / {
    root /home/user/html/web;
    index app.php;

### вот эту строчку я добавил для перенаправления
    rewrite "/stat/game.swf" http://another_server/stat/game.swf permanent;

    try_files $uri @rewriteapp;
}
 
location @rewriteapp {
    root /home/user/html/web;
    rewrite ^(.*)$ /app.php/$1 last;
}

Is it correct to do a redirect like this?
p.s. I am new to setting up nginx.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Zhivotnev, 2014-03-31
@teet

location =/stat/game.swf {
return 301 http://another_server/stat/game.swf ;
}

It will work faster and load less nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question