Apache 2.4 PHP-FPM .htaccess rewrite word press

I went with php-fpm for better performance and security with WordPress. With this it is my understanding if a site is compromised since it will be in it’s own pool using a different user account for each pool it will not be able to affect anything else on the server. If there is a better way please let me know.

The issue I am having is it seems rewrite rules in .htaccess are ignored using ProxyPassMatch in vhost:

ProxyPassMatch ^/(.*.php(/.*)?)$ unix:/run/php/site.com-fpm.sock|fcgi://localhost/home/site.com/public_html/

Switched to Sethandler:

<FilesMatch ".php$">
    SetHandler  "proxy:unix:/run/php/site.com-fpm.sock|fcgi://localhost/"

Still same issue. Tried tons of solutions and the only one that seems to work is putting the rules in the vhost config like so:

DirectoryIndex index.php index.html

RewriteEngine On
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteRule ^ - [L]
RewriteRule ^/[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) /$1 [PT]
RewriteRule ^/[_0-9a-zA-Z-]+/(.*.php)$ /$1 [PT]
RewriteRule . /index.php [PT]

Is this a solution I can run with? Is there a better solution? Will I be shooting myself in the foot or run into another limitation with this solution?

Read more here: Apache 2.4 PHP-FPM .htaccess rewrite word press

Leave a Reply

Your email address will not be published. Required fields are marked *