.htaccess - Automatically redirect subdomain to folder path? -
is possible automatically redirect subdomains folder (structure)? want change setup of site subdomain folder , there lot of redirects done, wondering if there automatic solution.
what want i.e.:
subfolder1.domain.com
to redirected (internal redirect, same top-level domain) www.domain.com/folder/subfolder1
where 'subfolder1' relative (not static). there general htaccess code can use? thanks
you can put code in htaccess (which has in document root folder)
rewriteengine on rewritecond %{http_host} ^((?!www\.).+?)\.(domain\.com)$ [nc] rewriterule ^(.*)$ http://www.%2/folder/%1/$1 [r=301,l]
note: redirect
in question, understood external redirect. if that's not case, i'll update answer
edit (internal rewrite)
rewriteengine on rewritecond %{http_host} ^((?!www\.).+?)\.domain\.com$ [nc] rewriterule ^((?!folder/).*)$ /folder/%1/$1 [l]
Comments
Post a Comment