.htaccess – redirect example.com to /wwwhome and www.example.com to /wwwweb

I want to redirect http://example.com((all subdomains) to /DOCUMENT_ROOT/wwwhome and http://www.example.com to /DOCUMENT_ROOOT/wwwweb,

I use the following .htaccess placed in the root of document_root.

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(.*)?example.com$
RewriteCond %{REQUEST_URI} !^/wwwhome/
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ /wwwhome/$1 [L]

RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/wwwweb/
RewriteRule ^(.*)$ /wwwweb/$1 [L]

www.example.com redirect ok, but www.example.com/directory~ redirect wrong url.
Please help me in this.
Thanks!

Read more here: .htaccess – redirect example.com to /wwwhome and www.example.com to /wwwweb

Leave a Reply

Your email address will not be published. Required fields are marked *