First case:
I tried to redirect http to https and following rule works well.
For example: http://subdomain.domain.com to https://subdomain.domain.com.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Second Case: I tried to redirect http://subdomain.domain.com to http://subdomain.domain/folder. For this I used this rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com
RewriteRule ^(.*)$ /folder/$1
I want these redirection:
http://subdomain.domain.com to https://subdomain.domain.com/folder
and
https://subdomain.domain.com to https://subdomain.domain.com/folder
I tried merging the above rules but no luck.
One more thing, I am not using .htaccess ,instead I put these rules to
/etc/apache2/sites-available/default.
Answering my own question.
Actually there are two files in
/etc/apache2/sites-available/I put the rule to redirect
httptohttpsasin
defaultfile andput rule to redirect to sub-domain's
folderasin
default-sslfile.