apache - Wordpress, redirect domain root to a subdomain -
a friend of mine asked wordpress site. did work under sub.domain.com
, he'd have domain.com
redirected it, if possible without showing sub
in url bar
this domain root .htaccess
# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress
following resources found, inserted these 2 lines after rewriteengine on
:
rewritecond %{http_host} ^sub\.domain\.com$ [nc] rewriterule ^(.*)$ http://domain.com/$1 [l,r]
but doesn't seem work, should simple doing wrong...
i tried commenting rest, didn't work
i not apache expert @ all, what's problem?
to redirect example.com/ sub.example.com/ ,you can use following :
rewriteengine on rewritecond %{http_host} ^(www\.)?domain\.com$ [nc] rewriterule ^$ http://sub.domain.com/$1 [l,r]
^$ matches root / of example.com ,if want redirect subdomain ,change pattern ^(.*)$ .
Comments
Post a Comment