Apache 2.4 with PHP-FPM .htaccess redirection
Your problem is that the .htaccess file is never read. .htaccess is only read after apache has determined that it needs to look for the resource requested on its local filesystem. You are however telling apache to forward the request to another process...
You will need to add the rewrites to your main config.
nwalke
Updated on September 18, 2022Comments
-
nwalke almost 2 years
I have Apache 2.4 set up with PHP-FPM on a server. To pass from Apache to PHP-FPM I use the following:
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9001/hosting_files/site.com/admin_secure/$1
"admin_secure" is the DocumentRoot in the vhost.
In that directory, I have a .htaccess file that contains the following:
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] </IfModule>
The site works, right up until I try to access something that should be in the
webroot
directory. For example, if I go tovendors/kcfinder/browse.php
which is inside thewebroot
directory, I get a "File not found" error. If I go towebroot/vendors/kcfinder/browse.php
, it works.I've turned on rewrite and proxy logging, and it looks like the rewrite never takes place. It just sends whatever I type in the URL (if it's a PHP file).
Is there a way to write my ProxyPassMatch statement to take in rewrites like that?
-
Kontrollfreak over 10 yearsEither that or dump mod_proxy_fcgi and use mod_fastcgi.