The server is configured to handle php files with fastcgi :

<IfModule mod_fastcgi.c>
    AddHandler application/x-httpd-php .php
    Action application/x-httpd-php /fcgi-bin/php-fpm virtual
    ScriptAlias /fcgi-bin/php-fpm /fcgi-extsrvs-phpfpm
    <Location "/fcgi-bin/php-fpm">
            Order Deny,Allow
            Deny from All
            Allow from env=REDIRECT_STATUS


Then a virtual host is defined to use this fastcgi :

<VirtualHost *:80>
    ServerName mydomain.org

    DocumentRoot /var/www/mydomain.org

    <Location />
        Order Allow,Deny
        Allow from All
        AllowOverride None

    <IfModule mod_fastcgi.c>
        # use the socket as defined for this pool
        FastCgiExternalServer /fcgi-extsrvs-phpfpm -socket /var/run/php5-fpm/mydomain.org.sock

    # problem here
    AliasMatch ^/(.*) /var/www/mydomain.org/index.php 


Everything is working fine, until I add the AliasMatch line (same problem with Alias). The goal is to handle every request with the index.php script. This cause a 500 error with the following log :

[error] [client 88.xxx.xxx.20] 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.
[debug] core.c(3112): [client 88.xxx.xxx.20] r->uri = /fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/
[debug] core.c(3118): [client 88.xxx.xxx.20] redirected from r->uri = /fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/fcgi-bin/php-fpm/
[debug] core.c(3118): [client 88.xxx.xxx.20] redirected from r->uri = /fcgi-bin/php-fpm/
[debug] core.c(3118): [client 88.xxx.xxx.20] redirected from r->uri = /

My guess is there is a conflict between the ScriptAlias and AliasMatch, but I don't know how to resolve it.

1 Answer 1


Her's a solution to a simmilar problem http://www.tokiwinter.com/avoiding-infinite-recursion-with-mod_rewrite-and-mod_fastcgi/ TL;DR use mod_rewrite and disabling rewriting for php script url

But I strongly suggest moving to apache2.4 and using mod_proxy_fcgi https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html where You can

<FilesMatch "\.php$">
    SetHandler  "proxy:unix:/var/run/php5-fpm/mydomain.org.sock|fcgi://host1/"

And with that all the redirects, rewrites should work as expected. BTW mod_fastcgi is outdated, and ugly. If You prefer to stay with 2.2 (which is EOL'ed now) You can try https://github.com/lazy404/mod_fastcgi_handler (I use it on a busy site with php-fpm without any problems) it's config is also clean and compatible with redirects.

  • oops it was asked 3y ago ;)
    – Lazy404
    May 31, 2016 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .