• 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.

Issue WordPress - 404 Page with nginx - Permalinks not working

rene1

New Pleskian
Hello,

I use Plesk 17 with Ubuntu 14.04, apache, nginx, redis and WordPress 4.7.
Now I´ve changed the WordPress Permalink to a more human friendly version.
But after changing the URL rewrite in WordPress, nginx can´t find the page.
When I change it back to the default url with /?pageid_=123 than nginx is working.

I´m not a Linux Guru (coming from Windows), but I want to use a WordPress installation of cause as fast a possible.

I found several instructions but it seems pretty hard also depending on the caching tool used with WordPress.

And the main question at the end is: Can I use these instructions with Plesk or is it breaking Plesk?

There is also an Plesk Extention, but how to use it?
What rules do I have to put into the fields?
https://ext.plesk.com/packages/b33b9ba7-72c7-43a5-8454-f58236340563-htaccess-to-nginx

How to fix Nginx 404 Error:
https://codex.wordpress.org/Nginx#General_WordPress_rules (This page is marked as incomplete.)
https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
This seams pretty short:
https://blog.hosnex.de/wordpress-nginx-404-error-url-rewrite/

Can I use easyengine in any way to setup all correct (if Plesk can´t give me an out of the box tool)?
https://easyengine.io/
https://vexxhost.com/resources/tutorials/how-to-install-and-use-easyengine-ee-on-ubuntu/
https://easyengine.io/wordpress-nginx/tutorials/single-site/redis_cache-with-conditional-purging/
https://easyengine.io/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/

Thanks in advanced.

Best regards,

Rene
 
Switch back to apache ..than install htaccess to nginix auto converter from extension catalog....and than switch again to nginx..it should convert htaccess rules...
 
Switch back to apache ..than install htaccess to nginix auto converter from extension catalog....and than switch again to nginx..it should convert htaccess rules...

Once I have tried it and didn't work for me.
 
How to do this after upgrade to Plesk Onyx?
Go to domains than select domain you want to mange,than you'll see PHP settings icon..open it and under php settings you can select how you want serve files..Apache FMP,Nginx FPM,apache or nginx FastCgi..etc.If htaccess to nginx extension don't convert on auto pilot ...under domain in Apache & nginx settings there will be converter where you can manualy add htaccess content and convert it.This extension worked for me but I have install it before website...that is why I told you to switch back to apache than to nginx...I suppose converter is trigered when you switch from apache to nginx...like i say I have uinstall it before website always..but there is no reason to not work in your case.Any way you can always put .htaccess content in converter box under Apache & nginx and convert manualy rules.
 
Hi,
i used Fast-CGI / Apache and i put the contentof the .htaccess file into the converter. But it doesn't work fine...
Is there a "workaround" from Plesk for these problems?
 
Hi,
i used Fast-CGI / Apache and i put the contentof the .htaccess file into the converter. But it doesn't work fine...
Is there a "workaround" from Plesk for these problems?
If you use Apache fastCGI than you don't need to convert any rules ...first you need to make sure everything is working on Apache than you can convert and switch to Nginx.If you have problems with permalinks under Apache than you have to fix it first and make sure everything works under apache.
Now i don't have enoughf information to provide you strict steps for work around but generally to make things right you should revert everything to point where it worked..or to start....
If I'm on your place I would first select Apache and revert to default WP url, than make sure there is only default htaccess content in .htaccess file(if default content is not auto-reverted you can easily find it online and put it by yourself) and now make sure everything is working on default settings.Than I would set prefered permalinks again and than only if everything work without issues under apache you are safe to switch to nginx..makes no sence to switch to Nginx if word press doesn't rewrite urls properly and doesn't work under apache...
Now to make things right you just need to have mod_rewrite enabled under apache(Tools & Settings-->Apache web server) and right permissions for WP installation...
 
Last edited:
Its easy to use only nginx for websites:

Use FPM with nginx and uncheck nginx as Proxy and past following Code into the box Additional nginx statements:

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}


Wait 10secs and reload your website :)

If you want, you can install a extension who do the same: htaccess to nginx 1.0
 
Its easy to use only nginx for websites:

Use FPM with nginx and uncheck nginx as Proxy and past following Code into the box Additional nginx statements:

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}


Wait 10secs and reload your website :)

If you want, you can install a extension who do the same: htaccess to nginx 1.0

If i do this, I get a:
502 Bad Gateway
 

Plesk use Nginx as a reverse-proxy by default, running WordPress with Nginx only will not make your website really faster, and doesn't allow to use .htaccess files.
With Nginx, the default rewrite rule for WP is :

Code:
location / {
  try_files $uri $uri/ /index.php?$args;
}


EasyEngine is a powerful command line tool to setup WordPress with Nginx and a caching system, but it's hard to make a comparison with Plesk, because that's not the same usage (DNS, MAIL, Backup).

You can use an avanced caching solution like redis with Plesk, and it's not required to use Nginx only mode.
 
I have the same issue with Plesk Onyx, Nginx-Proxy Mode and WordPress installed on a subdomain "blog". PHP 5.6 served via FPM using Nginx.

No matter which tip and config I use, the 404 still remains when using the permalink setting %postname% in WordPress.

Code:
location / {
    try_files $uri $uri/ /index.php?$args;
}
-> results in the error duplicate location "/" in /var/www/vhosts/system...

Code:
location = / {
    try_files $uri $uri/ /index.php?$args;
}
-> No change, still 404

Code:
if (!-e $request_filename) {
rewrite ^.*$ /index.php?$args last;
}
-> Error changes from nginx 404 to 'File not found.'

Has anyone an additional suggestion?
 
Last edited:
Back
Top