Reputation: 519
I have the following htaccess that is working:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.([^.]+)\.([^.]+)$ [NC]
RewriteRule ^ %1%{REQUEST_URI} [L]
I have 4 domains that point to the same server (domain.com)
example1.com
example2.com
example3.com
example4.com
Right now with the actual htaccess when i go to
test.example1.com
It will show the files from the directory
domain.com/test
Just how i want it.
But i need to implement a new feature.
So when i go to
test.example1.com
It needs to go to
domain.com/example1.com/test
and the same goes to
test2.example1.com ----> domain.com/example1.com/test2
test5.example2.com ----> domain.com/example2.com/test5
test6.example3.com ----> domain.com/example3.com/test6
test9.example4.com ----> domain.com/example4.com/test9
IT DOES NOT REDIRECT, it rewrites, i don't want it to redirect.
Upvotes: 1
Views: 89
Reputation: 785098
You can replace your existing rule with this:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.([^.]+\.[^.]+)$ [NC]
RewriteRule ^ %2/%1%{REQUEST_URI} [L]
Upvotes: 1