apache - htaccess www sub domain redirect -
my problem
i have sub domain pointing different server. server has ssl, when user types in sub domain: https://my.maindomain.co
works great. using htaccess i'm trying redirect users type in following web address: https://www.my.maindomain.co
or http://
equivalent correct version (https://my.maindomain.co).
i thought below work nicely not:
# rule removing www on sub domains rewritecond %{http_host} ^www\.([^.]+\.maindomain\.co)$ [nc] rewriterule ^ https://%1%{request_uri} [r=301,l]
anybody me out this?
for reference placing code in htaccess on maindomain.co server, hosted on different server my.maindomain.co
you can use rule subdomain on server sub domain hosted. should take care of requirements.
rewriteengine on rewritecond %{https} !^on [or] rewritecond %{http_host} !^my\.example\.co$ [nc] rewriterule ^ https://my.example.co%{request_uri} [r=301,l]
note must have valid ssl certificate www.my.example.co
work if enter www.my.example.co
. otherwise still handle redirecting http://my.example.co
https://my.example.co
.
Comments
Post a Comment