I have a redirect in place. If a request comes in to the root and the content is available in /website3 it pulls the content in from website3 but only displays the root request. This works really well. For example is a request comes in for example.com/foo/test/ and there is an index.htm file in /website3/foo/test the content displays without including website3 in the url. It also plays nicely if a different path exists like example.com/test it will go to the test directory. This is all perfect.
I am trying to factor out if the request comes in for example.com/website3/foo/test I would like this to redirect to example.com/foo/test but still pull in the content from website3. I have tried a few things and they all result in a loop.
Here is the current code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Remove trailing slash on any URL that is requested directly (excludes rewritten URLs)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule (.*)/$ /$1 [R=301,L]
# Rewrite root
RewriteRule ^$ website3/ [L]
# If request maps to a directory in "/website3" then rewrite and append trailing slash
RewriteCond %{DOCUMENT_ROOT}/website3/$1 -d
RewriteRule ^([^.]+)$ website3/$1/ [L]
RewriteCond %{DOCUMENT_ROOT}/website3/$1 -f
RewriteRule (.*) website3/$1 [L]