Welcome Guest, Not a member yet? Register   Sign In
Issues with mod_rewrite apache fastcgi with php fpm
#1

[eluser]kwhat4[/eluser]
I am having issues getting the rewrite rules and fastcgi to work together. As you can see from the logs, we are getting an awesome redirection loop from fastcgi to the index file and back again. I am guessing i need to add a rule to not apply the redirect after it was passed to fastcgi but im not sure which gets processed first. Has anyone dealt with an issue like this before? Thanks.

*** Update: The following seems to get some of the re-rewriting working however I am not sure if there is a better way to do it and what what needs to be done for the system and application rewrites.

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/cgi-bin/*
RewriteRule ^(.*)$ index.php?/$1 [L]


Code:
AddHandler php-fpm .php
Action php-fpm /cgi-bin/php-fpm

<Location /cgi-bin/php-fpm>
        Order Deny,Allow
        Deny from All
        # Prevent accessing this path directly
        Allow from env=REDIRECT_STATUS

        SetHandler fpm-script
        Options +ExecCGI
</Location>

AddType application/x-httpd-php .php

ScriptAlias /cgi-bin/ /var/www/siteroot/htdocs/
FastCgiExternalServer /var/www/siteroot/htdocs/php-fpm -socket /var/run/php-fpm.socket

<Directory /var/www/siteroot/htdocs>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</Directory>

Code:
[Fri Feb 18 00:17:32 2011] [error] [client ] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Fri Feb 18 00:17:32 2011] [debug] core.c(3063): [client ] r->uri = /cgi-bin/php-fpm/index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /cgi-bin/php-fpm/index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /cgi-bin/php-fpm/index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /cgi-bin/php-fpm/index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /cgi-bin/php-fpm/index.php
[Fri Feb 18 00:17:32 2011] [debug] core.c(3069): [client ] redirected from r->uri = /index.php
#2

[eluser]MVUG[/eluser]
try this: $config[‘uri_protocol’] = ‘QUERY_STRING’; (config.php)
#3

[eluser]kwhat4[/eluser]
***delete***
Fast replay ftw
#4

[eluser]kwhat4[/eluser]
Quote:try this: $config[‘uri_protocol’] = ‘QUERY_STRING’; (config.php)

Yah, that didn't make a difference. Its a redirection loop due to the handler for fastcgi fpm.
#5

[eluser]Remko Posthuma[/eluser]
Remove ? after the index.php so change it to:
RewriteRule ^(.*)$ index.php/$1 [L]

set the config to:
$config['uri_protocol'] = "PATH_INFO";

hope this helps




Theme © iAndrew 2016 - Forum software by © MyBB