Skip to main content
2 of 3
added 160 characters in body
anubhava
  • 790.3k
  • 67
  • 603
  • 671

You can use this rule in site root .htaccess:

RewriteEngine On # add a trailing slash if test/$1 is a directory RewriteCond %{DOCUMENT_ROOT}/test/$1 -d RewriteRule ^(.*[^/])$ %{REQUEST_URI}/ [L,R=301,NE] RewriteRule ^(?!test/)(.*)$ test/$1 [L,NC] 

(?!test/) is negative lookahead to skip rewrite when request is already starting with /test/

anubhava
  • 790.3k
  • 67
  • 603
  • 671