I've looked around and have attempted some rules and conditions that worked; while some did not work or the condition would capture too much causing other domains to also redirect. This works for me:
# Redirect (also catches www.)
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder [L]
resulting in if you visit www.domain.com OR domain.com being redirected to domain.com/subfolder Great, but I'dd also like the /subfolder part to be hidden from the url.
How do I achieve this ?
Note that I have multiple domains, each should redirect to its own folder. I also want each page to still be visible in its respective folder.
So www.domain.com/abc should redirect to domain.com/subfolder/abc but show domain.com/abc
Try this rule:
# remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule !^subfolder/ /subfolder%{REQUEST_URI} [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With