.htaccess - Redirect www.domain.com to sub.domain.com -
this question has answer here:
- generic htaccess redirect www non-www 21 answers
i'm trying redirect www.domain.com sub.domain.com except when url www.domain.com/something , in case keep way. couldn't find solution on google , anytime try implement in own, www.www.domain.com. in advance!
options +symlinksifownermatch options -indexes rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]
enable mod_rewrite , .htaccess through httpd.conf
, put code in .htaccess
under document_root
directory:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^(www\.)?domain\.com$ [nc] rewritecond %{request_uri} !^/something/?$ rewriterule ^ http://sub.domain.com%{request_uri} [r=301,l]
Comments
Post a Comment