Page 1 of 1

Wordpress Permalink issue - PHP FPM & NGINX subfolder

Posted: Sat Dec 31, 2022 5:34 pm
by kaleem
Hi All, i had an issue with Wordpress permalink.
My env is PHP-FPM & NGINX.

i tried wordpress2-rewrite templates but it dont work. i managed to fix the issue so wanted to post the solution here so others don't have to waste 2 days like me to fix the issue.
also, would prefer if is added to new verison of VestaCP.

basically I had wordpress installed in subfolder on domain.

so on domain https://kahrgroup.com and I had multiple subfolders with WordPress like /test1 , /test2 , /test3

if i allocate the default wordpress template (wordpress2_rewrite), it works good with install which reside in root but with any subfolder wordpress install when Permalink are changed to anything other than PLAIN they stop working and you get 404 error.

i created a new template (i have uploaded here for your reference if you want easy fix, just download these files and then copy these to templates folder and goto domain and click EDIT and select this template.

I have debian installed so templates reside in: /usr/local/vesta/data/templates/web/nginx/php-fpm (check with the distro you are using for right folder.)

https://kahrgroup.com/kaleem/wordpress-Subfolder.tpl

https://kahrgroup.com/kaleem/wordpress-Subfolder.stpl

One is for HTTP & 2nd for HTTPS (you need to copy both)

Major change was regex :

Code: Select all

 if (!-e $request_filename)
        {
            rewrite ^(/[^/]+) $1/index.php?q=$1 last;
        }
Hope it sorts it out for those who are struggling.

Regards,
Kaleem