From your comment I know that you are using nginx. Nginx need a bit different configuration than Apache. Probably your current nginx vhost looks like that.
server {
listen *:80;
server_name test.dev;
root /var/www/test;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html;
location / {
# try to serve file directly, fallback to index.php
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9070;
}
}
The key part of this configuration is:
location / {
# try to serve file directly, fallback to index.php
try_files $uri $uri/ /index.php?$args;
}
it tell us something like that:
For location beginning with /
character try to load file from file system and if there is no such a file rewrite to index.php with arguments.
So thats why when you are trying to visit your subdir site it is working for something like /subdir/index.php?p=100
because file /subdir/index.php
is existing so there is no need for redirection. However when you try to visit /subdir/lorem-ipsum/
you will be redirect to home because there is no /subdir/lorem-ipsum/
file.
Correct configuration for both root and subdir WordPress installation will be:
server {
listen *:80;
server_name test.dev;
root /var/www/test;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html;
location / {
# try to serve file directly, fallback to index.php
try_files $uri $uri/ /index.php?$args;
}
location /subdir {
# try to serve file directly, fallback to index.php
try_files $uri $uri/ /subdir/index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9070;
}
}
PS. Nginx doesn’t care about .htaccess you can remove it.