Support » Fixing WordPress » Incorrect admin redirects 404, WordPress Traefik subdirectory

  • moussamango

    (@moussamango)


    Hi !
    I host a WordPress (5.4) website on my server.
    I use Traefik (2.2) as edge router and Docker (19.03) as provider.
    Currently, WordPress is in a docker which is accessible as a subdirectory of my subdomain.
    To access the wordpress site, I request:
    https://subdomain.domain.com/my_blog
    It is then routed by Traefik to the WordPress docker.
    The ‘siteurl and ‘home’ variables are updated in the database with the following value:
    https://subdomain.domain.com/my_blog
    The ‘wp-config.php’ is also edited with :

    define('WP_SITEURL', 'https://subdomain.domain.com/my_blog');
    define('WP_HOME', 'https://subdomain.domain.com/my_blog');

    I can access and navigate in the website. My homepage or any other page like https://subdomain.domain.com/my_blog/my_page are accessible and correctly redirected.
    In fact, the routing works quite well except in the ADMIN section.
    The redirection sent by WordPress from the ‘wp-admin’ pages are incomplete:
    – instead of having my whole site URL
    https://subdomain.domain.com/my_blog/wp-admin/some_pages
    I get
    https://subdomain.domain.com/wp-admin/some_pages
    This returns HTTP 404 Not found. It misses the ‘/blog’ in the redirection…

    Example1:

    – When on the admin login, I log in, the wordpress log indicates:

    "POST /wp-login.php HTTP/1.1" 302 1184 "https://subdomain.domain/my_blog/wp-login.php?redirect_to=https%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1"

    The authentication is delivered but the ‘/my_blog’ is missing in the redirection. I can’t get to the correct route and a HTTP 404 is returned.
    The authentication is OK for the session. So, I can successfully access to the wp-admin dashboard by requesting:
    https://subdomain.domain.com/my_blog/wp-admin

    Yet, all the URLs generated in this admin dashboard page won’t refer to the:
    https://subdomain.domain/my_blog/wp-admin/some_file
    – instead they are just heading to ‘/some_file’
    So, HTTP 404 error answer when requested because Traefik doesn’t know this route:
    https://subdomain.domain/wp-admin/some_file

    Strangely, all the ‘href’ in the admin dashboard ‘welcome_panel’ elements refers to the correct URL:
    https://subdomain.domain/my_blog/wp-admin/some_file
    (HTTP 200 OK answer when requested)

    Whereas, all ‘.php’ ref on the same dashboard lead to
    ‘some_file.php’
    instead of:
    https://subdomain.domain/my_blog/wp-admin/some_file.php

    Example2:

    – Another strange thing is:
    When on the admin ulpoad page:
    (at https://subdomain.domain/my_blog/wp-admin/upload.php)
    All ‘href’ and ‘pages.php’ consider my full ‘site_url’ in their ‘href’. (HTTP 200 answer):
    "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 456 "https://subdomain.domain.com/my_blog/wp-admin/upload.php"

    Current hypothesis:
    It seems some ‘href’ links correctly consider the ‘site_url’ variable while most of them don’t. They are all generated by a wordpress redirect so I suspect the issue is in WordPress, not in Traefik routing.

    I think about editing the ‘.htaccess’ file but I need help with it.
    Plus, isn’t the ‘.htaccess’ for rewriting the HTTP GET incoming requests?

    Thanks for the support !

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.