• So I decided to try to move yet another WordPress website to our main server, and since it has never been a multisite version, I decided to put it inside a subdirectory and create a .htaccess redirection. So

    – a DNS alias is set up to the server root (where our main wordpress multisite lives)
    – the website is installed inside a subdirectory, call it subdir
    – the root htaccess checks for domain name and redirects:
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.xy
    RewriteCond %{REQUEST_URI} !^/subdir/
    RewriteRule ^(.*)$ /subdir/$1 [L]
    – the subdir htaccess is a common WordPress htaccess rules file

    Everything runs smoothly except for media files inside /subdir/wp-content/uploads/.* – these files are getting 404. I found out that all such links were in fact treated as pages. Furthermore, debugging both htaccess files with minimal example approach has shown that
    – links that begin with wp-content/uploads get trimmed, so that domain.xy/wp-content/uploads/dir/file.png is ALWAYS dir/file.png in BOTH .htaccess files (redirected all to a custom php script using QSA,L that printed out $_GET, even as the first rule of the parent htaccess).
    – other links, for example domain.xy/subdir/wp-content[...]file.png work flawlessly
    – with RewriteRule (.*\.(js|css|ico|gif|png|jpg|jpeg|webp)) /subdir/wp-content/uploads/$1 [L] all seems fine but this is not a fix since media files can be elsewhere
    – there are no .htaccess files in the child directories
    – there are no problems with file privileges

    I have no access to the apache/php configuration.

    Simply, wp-content/uploads part vanishes from REQUEST_URI for the domain – if it starts with it. Thank you for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    It looks like the site is still directing to the multisite via URL structure. I suggest trying to recreate the WordPress permalinks of the website in the first place.

    If the issue persists, I recommend checking up on this step-by-step on how to revert website linking from multisite to a single site.

    Thread Starter aiosa

    (@aiosa)

    Hello, thank you for your answer, permalink re-creation was among the first things we’ve tried.
    I would also guess the URL gets somehow inside the multisite if I hadn’t tried out having the root htaccess to redirect _all_ traffic to the subdirectory, even the root multisite loaded as if it was alias for domain.xy.

    /.htaccess contents:

    RewriteCond %{REQUEST_URI} !^/subdir/
    RewriteRule ^(.*)$ /subdir/$1 [L]
    

    The behavior’s the same. Since this is all the htaccess file contained for the while, it should be impossible to access anything from the multisite. Any .../wp-content/uploads.* link was still getting trimmed.

    • This reply was modified 1 year, 7 months ago by aiosa.
    • This reply was modified 1 year, 7 months ago by aiosa.
    • This reply was modified 1 year, 7 months ago by aiosa.
    • This reply was modified 1 year, 7 months ago by aiosa.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress install in subdirectory’ is closed to new replies.