server level url rewrite & config rewrite or internal redirection cycle
Igor Sysoev
igor at sysoev.ru
Sun Dec 6 12:23:53 MSK 2009
On Sun, Dec 06, 2009 at 12:03:40PM +0300, Igor Sysoev wrote:
> 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.
Probably, you need to prepend /home/test in all directives.
Also probably, you do not need regexes at all:
location = /favicon.ico {
root /home/test/frontend/template/default/img;
}
location /img/ {
root /home/test/frontend/template/default;
}
location /js/ {
root /home/test/frontend/template/default;
}
location /b_js/ {
alias /home/test/bframe/frontend/cache/js_cache/;
}
location /css/ {
root /home/test/frontend/template/default;
}
location /html/ {
root /home/test/frontend/;
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list