• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

htaccess rewrite rules are not executed on some urls with php-fpm

Peter77

New Pleskian
Imagine a htaccess file like this:

RewriteEngine on
RewriteRule !^proxy/index.php$ index.php [L]

And index.php is the only php file in the directory proxy. Now all urls like proxy/.. should be rewritten to index.php. This does not work for urls like proxy/foo.php (404 file not found). It works fine with the previous php-fgci.

The reason may be the new "ProxyPassMatch" directive in vhost-config?
 
Hi Peter77,

please be so kind to provide MORE information about your system and its configuration ( in this case: apache only? apache + nginx combination? Are you aware that nginx ignores all .htaccess - files and needs additional nginx directives? Which operating system? Which Plesk version ( incl. MU )? ... the more information you provide, the better will be suggestions and investigations to your issue!!! ). If you experience issues/problems errors, please include log - entries.

 
Sorry, here is some more information:

- I use an up-to-date Plesk-12.5.30 on Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-042stab111.12 x86_64)
- Apache only
- Since I just upgraded to Plesk-12.5 from Plesk-12.0.18, I tried to use the new possibility to switch to php-fpm with a domain.

Please notice, that the rewrite-rule in htaccess file above works with php-fpm for other urls like "mydomain.com/proxy/test/test.html", but if the path contains ".php" like "mydomain.com/proxy/foo.php" and "foo.php" does not exist, a 404-error is shown, but it should also rewrite "mydomain.com/proxy/foo.php" to ""mydomain.com/proxy/index.php", which works in php-fcgi.
 
Hi Peter77,

I would suggest, to use "normal" rewrite rules, as for example:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /proxy/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /proxy/index.php [L]
</IfModule>
 
Hi Peter77,

please check, that your domain specific php socket is actually existent at "/var/www/vhosts/system/example.com/php-fpm.sock"

Consider to add additional http/https directives at: Home > Subscriptions > example.com > Websites & Domains > Apache & nginx Setting

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/www/vhosts/system/example.com/php-fpm.sock|fcgi://127.0.0.1:9000/var/www/vhosts/example.com/httpdocs
 
The problem seems, that proxypassmatch directive prevents the rewrite rules to be executed correctly.
 
Last edited:
as last post, the solution for apache>=2.4.10 (plesk on ubuntu currently uses 2.4.7), this is from the current apache mod_proxy_gcfi manual:

You can also force a request to be handled as a reverse-proxy request, by creating a suitable Handler pass-through. The example configuration below will pass all requests for PHP scripts to the specified FastCGI server using reverse proxy. This feature is available in Apache HTTP Server 2.4.10 and later. For performance reasons, you will want to define a worker representing the same fcgi:// backend. The benefit of this form is that it allows the normal mapping of URI to filename to occur in the server, and the local filesystem result is passed to the backend. When FastCGI is configured this way, the server can calculate the most accurate PATH_INFO.

Proxy via Handler
<FilesMatch"\.php$">
# Note: The only part that varies is /path/to/app.sock
SetHandler"proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy fcgi://localhost/ enablereuse=on max=10>
</Proxy>

<FilesMatch...>
SetHandler"proxy:fcgi://localhost:9000"
</FilesMatch>

<FilesMatch...>
SetHandler"proxy:balancer://myappcluster/"
</FilesMatch>
 
Last edited:
Hello UFHH01 , Peter77

My server run on Debian 7.9 , Plesk v12.5.30 and Apache 2.2 not 2.4 , How can i fix 404 Not Found nginx ? Or i should to wait Plesk to fix this on the next update.
Please help. Thank you
 
Back
Top