server level url rewrite & config rewrite or internal redirection cycle
Igor Sysoev
igor at sysoev.ru
Sun Dec 6 12:03:40 MSK 2009
On Sat, Dec 05, 2009 at 04:33:15AM -0500, et wrote:
> I am using "nginx version: nginx/0.7.64", the latest stable version.
> I notice that rewrite on the server level won't respect the 'break' or 'last' flag. Is this a feature or a bug? According to the module doc, it should be a bug.
>
>
> server {
> listen 80;
> server_name hellogrow.corp.yahoo.com;
> root /home/test;
>
> error_log logs/host.error.log notice;
> rewrite_log on;
>
> rewrite ^/favicon.ico(\?.*|)$ /frontend/template/default/img/favicon.ico break;
> rewrite ^/img/(.*\.(jpg|png|gif))$ /frontend/template/default/img/$1 break;
> rewrite ^/js/(.*\.js)$ /frontend/template/default/js/$1 break;
> rewrite ^/b_js/(.*\.js)$ /bframe/frontend/cache/js_cache/$1 break;
> rewrite ^/css/(.*\.css)$ /frontend/template/default/css/$1 break;
> rewrite ^/html/(.*)$ /frontend/html/$1 break;
> }
What do you want to get ? Probably you need just:
location = /favicon.ico {
root /frontend/template/default/img;
}
location ~ ^/img/(.*\.(jpg|png|gif))$ {
root /frontend/template/default;
}
location ~ ^/js/(.*\.js)$ {
root /frontend/template/default;
}
location ~ ^/b_js/(.*\.js)$ {
alias /bframe/frontend/cache/js_cache/$1;
}
location ~ ^/css/(.*\.css)$ {
root /frontend/template/default;
}
location /html/ {
root /frontend/;
}
without these ugly rewrites.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list