I’m using a cPanel account to host multiple sites. To have a clean public_html, I use .htaccess to redirect the main domain into one of the subfolders.
So when user types in www.example.com, it will be rewritten into www.example.com/mainsite/ but still showing www.example.com in the URL.
But when using the codes below, every domain (including sub domains) will get redirected to that folder:
RewriteCond %{REQUEST_URI} !^/example
RewriteRule ^(.*)$ /mainsite/$1 [NC,L]
How can I target only www.example.com (and www.example.com/files) to be rewritten to the /mainsite?
*Other subdomains should be pointing to their own Document_Root as created.
2
Answers
You need one more
RewriteCond
to check for main domain:Do this, This line helps me solve the issue.