Weird redirection on a Custom Web App (Wordpress) install after changing the app URL

My YunoHost server

Hardware: Raspberry Pi 4 Model B
YunoHost version: 4.0.8.3 (stable) behind Freebox mini 4K
I have access to my server : Through SSH, through the webadmin

Description of my issue

Hi!

I’m trying to setup a worpdress install as a custom web app on my Yunohost server. I managed to install wordpress, migrate my content from a previous wordpress install on another server, and import all the content and config using wordpress duplicator plugin.

I first assigned the following URL to the custom app: https://mysite.fr/site (fake URL, I can provide the right one if needed), But I set it up afterwards to the root of the domain, https://mysite.fr. It’s also the URL in both wordpress settings (Wordpress URL and website’s URL).

There’s a strange behaviour now: I can easily access to the admin through mysite.fr/wp-admin or mysite.fr/wp-login, but when I visit https://mysite.fr, there’s an automatic redirection to https://mysite.fr/site, and consequently a nginx 404 error.

Did I forget to set up something? Where can I check if there’s still a redirection somewhere that I could have forgotten?

Thanks a lot for your help!

Eh okay can you elaborate on how you did this ?

Maybe let’s check the content of the persistent ssowat conf :

cat /etc/ssowat/conf.json.persistent

Through the Yunohost graphic admin of the apps, “Modifier l’URL d’accès de cette application (domaine et/ou chemin)” (fr). Does it sound odd to do that?..

(NB : If i check the server through FTP, with the custom webapp credentials, the worpress files are at the root of the www folder.)

There it is indeed:

{"redirected_urls": {"mapper.fr/": "mapper.fr/site"}}

Is it good enough if I edit conf.json.persistent to remove the line?

Not really but there are multiple ways to achieve similar result which may or may not lead to that issue :stuck_out_tongue_winking_eye: In particular I’m guessing that you may have used the “Make this app the default one” considering the presence of ‘redirected_urls’ in conf.json.persistent

Yes, it’s in fact a ~bug of the “Make this app the default” I believe …

You can edit the file using your favourite tool, or also :

echo '{}' > /etc/ssowat/conf.json.persistent

(no need to restart anything for this to take effect except maybe force-clearing the browser cache with Ctrl+F5)

1 Like

Yep I did used this now that you mention it. It was pretty much “try and see” at this stage! :smile:

Ok I did this. Now the root of the domain displays appropriately, as well as the admin, but every other link on the website still leads to a 404…

I’m gonna investigate to try to understand where it comes from and I’ll report back here. Thanks a lot for your help!!

I found the issue: in Wordpress settings, the permalinks were set to custom to show “pretty” human readable URLs, and according to (1) NGINX seems to not support it. If I set the URLS to default (“simple”), it works again. However I’d like to keep the pretty URLs if I can…

The page in (1) suggests to modify nginx.conf to add the following lines to modify NGINX behavior:

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

Is it safe to do it in Yunohost context? I’m using the same Yunohost server to host my Nextcloud service and a couple of other apps. Won’t it break something? Since I’m using mapper.fr only for the Wordpress, and another domain for the rest of the apps, maybe there’s a way to limit the NGINX “location” directive or block to mapper.fr?

I hope my questions are clear. Once again, thank you very much for your time and help :slight_smile:

(1) https://nginxlibrary.com/wordpress-permalinks/

Hi,

A quick update to this issue!

I found out that there could be different conf files in /etc/nginx/conf.d, including one called mondomaine.fr.conf - that’s the domain associated with my Wordpress custom webapp. But there’s also a folder called mondomaine.fr.d, in which I found my_webapp.conf. Which file does what ? Don’t know yet.

  • I tried to update mondomaine.fr.conf with the location block and reload nginx but pretty URLs still don’t work.
  • The appropriate location block was already included in my_webapp.conf.

I’m a bit lost now, any help appreciated!

Thanks.

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