WordPress install in subdirectory
-
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 itsubdir
– 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 fileEverything 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 withwp-content/uploads
get trimmed, so thatdomain.xy/wp-content/uploads/dir/file.png
is ALWAYSdir/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 exampledomain.xy/subdir/wp-content[...]file.png
work flawlessly
– withRewriteRule (.*\.(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 privilegesI 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.
- The topic ‘WordPress install in subdirectory’ is closed to new replies.