Redirect http to https and then redirect it to a subdomain folder?

The first case:

I tried redirecting http to https and the following rule works well.

For example: http://subdomain.domain.com https://subdomain.domain.com .

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Second case: I tried redirecting 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 to redirect:

http://subdomain.domain.com to https://subdomain.domain.com/folder

and

https://subdomain.domain.com to https://subdomain.domain.com/folder

I tried to merge the above rules, but no luck.

, .htaccess, /etc/apache2/sites-available/default.

+4
1

.

/etc/apache2/sites-available/

:
  • -SSL

http https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

default

folder

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com  
RewriteRule ^(.*)$ /folder/$1

default-ssl.

+1

All Articles