Проблема с index index.html и rewrite

Владислав Комиссаров vk at shiloff.ru
Fri Aug 15 16:09:52 MSD 2008


Ситуация следующая.

server {
...
  set $srv_root  /var/www/domain.ru/htdocs;
...

  location / {
    root $srv_root;
    index index.html;

    if (!-f $request_filename){
        rewrite (.*) /index2.html;
    }
  }

  location /public/ {
      root $srv_root;
  }
}

При таком конфиге, я ожидаю что при запросе http://www.domain.ru/ будет
произведен внутренний редирект на /index.html, который не попадет в !-f
$request_filename и сервер отдаст клиенту /var/www/
domain.ru/htdocs/index.html, но вместо этого клиенту отдается index2.html

Есть предположение, что при внутреннем редиректе на /index.html в
$request_filename остается "/".

Если запросить http://www.domain.ru/index.html - все отдается верно.

/usr/local/nginx/sbin/nginx -V
nginx version: nginx/0.7.10
built by gcc 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
configure arguments: --conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access_log
--error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx.pid
--http-client-body-temp-path=/var/tmp/nginx/client
--http-proxy-temp-path=/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --with-pcre=../pcre-7.7
--with-zlib=../zlib-1.2.3 --without-select_module --without-http_ssi_module
--without-http_userid_module --without-http_auth_basic_module
--without-http_geo_module --without-http_map_module
--without-http_referer_module --without-http_memcached_module
--without-http_empty_gif_module --without-http_browser_module
--without-http_upstream_ip_hash_module --without-mail_pop3_module
--without-mail_imap_module --without-mail_smtp_module
--with-http_stub_status_module
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20080815/dea51956/attachment.html>


More information about the nginx-ru mailing list