# Rewrite or internal redirection cycle while internally redirecting to "/error/403.html"

**URL:** <https://www.ruby-forum.com/t/rewrite-or-internal-redirection-cycle-while-internally-redirecting-to-error-403-html/224550>\
**Category:** NGINX\
**Created:** [November 16, 2012, 7:29am UTC](https://www.ruby-forum.com/t/rewrite-or-internal-redirection-cycle-while-internally-redirecting-to-error-403-html/224550 "2012-11-16T07:29:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 16, 2012, 7:29am UTC](https://www.ruby-forum.com/t/rewrite-or-internal-redirection-cycle-while-internally-redirecting-to-error-403-html/224550/1 "2012-11-16T07:29:15Z")

</div>

When accessing a vhost on my server I receive a 500 internal server  
error  
and then when viewing the log file I find the error rewrite or internal  
redirection cycle while internally redirecting to “/error/403.html”. I  
have a site working just fine with the exact same vhost configuration.  
All  
paths in the config are valid and all permissions are valid and correct.  
Below is the configuration for the vhost in question. Any assistance  
would  
be greatly appreciated.

server {  
listen \*:80;

```
    server_name somedomain.tld *somedomain.tld;

    root /var/www/somedomain.tld/web;

    index index.html index.htm index.php index.cgi index.pl 

```

index.xhtml;

```
    error_page 400 /error/400.html;
    error_page 401 /error/401.html;
    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 405 /error/405.html;
    error_page 500 /error/500.html;
    error_page 502 /error/502.html;
    error_page 503 /error/503.html;
    recursive_error_pages on;
    location = /error/400.html {
        internal;
    }
    location = /error/401.html {
        internal;
    }
    location = /error/403.html {
        internal;
    }
    location = /error/404.html {
        internal;
    }
    location = /error/405.html {
        internal;
    }
    location = /error/500.html {
        internal;
    }
    location = /error/502.html {
        internal;
    }
    location = /error/503.html {
        internal;
    }

    error_log /var/log/ispconfig/httpd/somedomain.tld/error.log;
    access_log /var/log/ispconfig/httpd/somedomain.tld/access.log

```

combined;

```
    ## Disable .htaccess and other hidden files
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /stats {
        index index.html index.php;
        auth_basic "Members Only";
        auth_basic_user_file

```

/var/www/clients/client3/web3/.htpasswd\_stats;  
}

```
    location ^~ /awstats-icon {
        alias /usr/share/awstats/icon;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/lib/php5-fpm/web3.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
fastcgi\_param PATH\_INFO $fastcgi\_script\_name;  
fastcgi\_intercept\_errors on;  
}

}

Thank You,

Landon L.

---

<div class="post-metadata">

**Author:** ![Landon\_Loucel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5e9695/32.png) [@Landon\_Loucel](https://www.ruby-forum.com/u/Landon_Loucel)\
**Post date:** [November 16, 2012, 9:28am UTC](https://www.ruby-forum.com/t/rewrite-or-internal-redirection-cycle-while-internally-redirecting-to-error-403-html/224550/2 "2012-11-16T09:28:27Z")

</div>

Hello!

On Fri, Nov 16, 2012 at 12:28:45AM -0600, Landon Loucel wrote:

> When accessing a vhost on my server I receive a 500 internal server error  
> and then when viewing the log file I find the error rewrite or internal  
> redirection cycle while internally redirecting to “/error/403.html”. I  
> have a site working just fine with the exact same vhost configuration. All  
> paths in the config are valid and all permissions are valid and correct.  
> Below is the configuration for the vhost in question. Any assistance would  
> be greatly appreciated.
> 
> server {  
> listen \*:80;

[…]

> ```
> error_page 400 /error/400.html;
> error_page 401 /error/401.html;
> error_page 403 /error/403.html;
> error_page 404 /error/404.html;
> error_page 405 /error/405.html;
> error_page 500 /error/500.html;
> error_page 502 /error/502.html;
> error_page 503 /error/503.html;
> recursive_error_pages on;
> 
> ```

You activated “recursive\_error\_pages”, hence any error which will  
in turn result in the same error again will cause infinite loop.  
With 403 it’s trivial to cause this effect e.g. by configuring  
insufficient permissions on document root (any path componenent  
of it).

That’s, in particular, one of the reasons why  
recursive\_error\_pages is off by default, and it’s not recommended  
to change this unless you understand what are you doing.

[…]

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
