Этого можно добиться с помощью mod_rewrite, поместив что-то подобное в файл .htaccess
вашей корневой папки:
RewriteEngine on
# the first condition is for avoiding an infinite loop
RewriteCond %{REQUEST_URI} !^/test/.*
RewriteRule ^(.*)$ /test/$1
Это перенаправит на /test/
все страницы / файлы, запрошенные у /
.
Если вы хотите перенаправить только некоторые файлы, используйте более конкретные правила:
RewriteEngine on
# the condition is for avoiding an infinite loop
RewriteCond %{REQUEST_URI} !^/test/.*
# redirecting only images files and files that start with "doc"
RewriteRule ^(.*\.(jpg|png|gif))$ test/$1 [L]
RewriteRule ^(doc.*)$ test/$1 [L]
Или, если вы хотите использовать разные папки:
RewriteEngine on
# the condition is for avoiding an infinite loop
RewriteCond %{REQUEST_URI} !^/images/.*
RewriteCond %{REQUEST_URI} !^/docs/.*
# redirecting only images files and files that start with "doc"
RewriteRule ^(.*\.(jpg|png|gif))$ images/$1 [L]
RewriteRule ^(doc.*)$ docs/$1 [L]