404 on pages if Wordpress is installed as custom app? After moving from old host to YH

My YunoHost server

Hardware: AMD 64
YunoHost version: 4.2.8 (stable).
I have access to my server : Yes

Description of my issue

I’ve migrated some WP sites from my old hosting provider to YH and everything went well, the sites are reachable and work fine. HOWEVER! If I change the permalinks to website.domain/page/something, I get NGINX 404 errors and if i set them to ?pageid=xxx it works fine. i tried all the tricks like changing permalinks and set them back and such.

Here are some pics;

Look at the URL works fine…

With these settings, it works…

Now let’s set it the way I want…

#Sadface :frowning:

If anyone knows? Thanks!

I think you can “steal” NGINX’s conf for the Wordpress app, notably the if block:

1 Like

Where is that file? The folder structure you gave doesn’t make any sense :wink:
/ and then? thank you!

The file to alter is /etc/nginx/conf.d/YOURDOMAIN.d/my_webapp.conf (or my_webapp__2, 3, etc. depending on the number of times you installed it.)

It should currently look like this. Alter it to look like that: (only add the lines I quoted earlier, since it contains __PLACEHOLDERS__)

#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {

    # Path to source
    alias __FINALPATH__/www/;

    # Force usage of https
    if ($scheme = http) {
        rewrite ^ https://$server_name$request_uri? permanent;

    # Default indexes and catch-all
    index index.html index.php;
    try_files $uri $uri/ __PATH__/index.php?$args;

    # Prevent useless logs
    location = __PATH__/favicon.ico {
        log_not_found off;
        access_log off;
    location = __PATH__/robots.txt {
        allow all;
        log_not_found off;
        access_log off;

    # Deny access to hidden files and directories
    location ~ ^__PATH__/(.+/|)\.(?!well-known\/) {
        deny all;

    if (!-e $request_filename)
           rewrite ^(.+)$ __PATH__/index.php?q=$1 last;
    # TO THERE

    # Execute and serve PHP files
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $request_filename;

    # Include SSOWAT user panel.
    include conf.d/yunohost_panel.conf.inc;

I have never tested that, so… :crossed_fingers:

1 Like

Schermafbeelding 2021-09-03 om 00.25.23

So even after restarting the service, it seems that it is not taking any effect. I did the positioning of the if statement right, right?

It looks like it yeah, besides an additional space before the if (but NGINX does not care). However, you forgot to replace __PATH__ with the actual path. :stuck_out_tongue: It should be the same as at the very top of the file: location __PATH__/ {.

I’m of track, and my brains are scrambled after a night of work and no sleep. Could you maybe be more clear, maybe a side by side view or replaceable file?

! Caution hardware ID: 1e2z34okrfkf4
WARNING: This developer is dazed and confused, he tries to continue but seems stuck in a boot loop. Some kernels appear to be in panic mode.

No, I cannot, since I do not know what is in your file. :wink:
edit: It looks like the app is installed at the root of a domain, so remove __PATH__ competely and leave only a /.

That’s more related to your other support thread. :wink:

Please read again this was more related to myself :smiley: but I rebooted myself ;-).

If no changes were made automatically, then the file is as “standard” as is installed.

But I made the changes correctly, and now it works ;-). I was just too busy last week to keep things from haywire in my brain.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.