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.

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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: