# Location directive causing a redirect?

**URL:** <https://www.ruby-forum.com/t/location-directive-causing-a-redirect/195283>\
**Category:** NGINX\
**Created:** [September 21, 2010, 5:50am UTC](https://www.ruby-forum.com/t/location-directive-causing-a-redirect/195283 "2010-09-21T05:50:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WSandrew\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d07c76/32.png) [@WSandrew\_L](https://www.ruby-forum.com/u/WSandrew_L)\
**Post date:** [September 21, 2010, 5:50am UTC](https://www.ruby-forum.com/t/location-directive-causing-a-redirect/195283/1 "2010-09-21T05:50:43Z")

</div>

Using the following configuration, causes a request for  
[Domain Blog | Domain, Website, and Ecommerce Tips for Small Businesses](http://domain.com/blog) to 301 to [Domain Blog | Domain, Website, and Ecommerce Tips for Small Businesses](http://domain.com/blog/) even with debug on error  
log I cannot see where this is happening in nginx.

```
location ^~ /blog/ {
  rewrite ^/blog(.*)$ $1 break;

  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host blog.onehub.com;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-Proto http;

  set $do_not_cache '';
  if ($http_cookie ~*

```

“comment\_author\_|wordpress\_(?!test\_cookie)|wp-postpass\_”) {  
set $do\_not\_cache 1;  
}

```
  proxy_cache_key "$scheme://$host$request_uri $do_not_cache";
  proxy_cache blog;
  proxy_cache_valid 200 302 60m;
  proxy_cache_valid 404 1m;

  proxy_pass http://blog;
}

```

---

<div class="post-metadata">

**Author:** ![WSandrew\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d07c76/32.png) [@WSandrew\_L](https://www.ruby-forum.com/u/WSandrew_L)\
**Post date:** [September 21, 2010, 10:46am UTC](https://www.ruby-forum.com/t/location-directive-causing-a-redirect/195283/2 "2010-09-21T10:46:18Z")

</div>

Hello!

On Mon, Sep 20, 2010 at 08:49:13PM -0700, W. Andrew Loe III wrote:

> Using the following configuration, causes a request for  
> [domain.com/blog](http://domain.com/blog) to 301 to [domain.com/blog/](http://domain.com/blog/) even with debug on error  
> log I cannot see where this is happening in nginx.
> 
> ```
> location ^~ /blog/ {
> 
> ```

[…]

> ```
> proxy_pass http://blog;
> }
> 
> ```

Locations ending with ‘/’ with proxy\_pass (fastcgi\_pass, …) will  
do implicit directory like redirect (“/blog” → “/blog/”). Grep  
for ‘auto\_redirect’ in sources.

Maxim D.

---

<div class="post-metadata">

**Author:** ![WSandrew\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d07c76/32.png) [@WSandrew\_L](https://www.ruby-forum.com/u/WSandrew_L)\
**Post date:** [September 21, 2010, 7:23pm UTC](https://www.ruby-forum.com/t/location-directive-causing-a-redirect/195283/3 "2010-09-21T19:23:50Z")

</div>

Thank you!

This is actually the behavior I want, I wanted to confirm my  
configuration was correct and that it wasn’t happening for some other  
reason which I might randomly break.
