On a shared server I am forced to manage document roots of domains from cpanel which is buggy and consumes lots of time. So I redirected all domains to one directory lets say root
. An example:
sd1.domain.com ---> public_html/web/
sd2.domain.com ---> public_html/web/
sd1.domain2.com ---> public_html/web/
sd2.domain2.com ---> public_html/web/
When user browses these websites, I forward this websites using htaccess rules such as
RewriteCond %{HTTP_HOST} ^sd1.(domain1|domain2).com [NC]
RewriteCond %{REQUEST_URI} !^/sd1/.*
RewriteRule ^(.*) sd1/$1 [L]
Now this does forward the request to different folder but afterwards all the url have sd1
attached on the last part
Here is an illustration
sd1.domain.com ---> sd1.domain.com #Works correctly
sd1.domain.com/page1.html ---> sd1.domain.com/sd1/page1.html # See the word sd1 on the middle
How to remove the folder portion from the url??