How to redirect to a folder and HTTPS at the same time?

3

I have a site link which is a CNAME from link , where the hosted site is hosted. But I needed to be redirected to the meusite folder of my amazon machine, ie link , but keep it only visible link .

I got this with this answer: link

RewriteEngine on 

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTP_HOST} ^(www.)?meusite.pt$ 
RewriteCond %{REQUEST_URI} !^/meusite/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ /meusite/$1 

RewriteCond %{HTTP_HOST} ^(www.)?meusite.pt$ 
RewriteRule ^(/)?$ meusite/ [L]

My problem now is that I also need to redirect from http to https, that is, if I type link it will redirect to link you will need to go to the content link .

The certificate is in meusite.pt .

Is it possible to do this with .htaccess ? How?

[EDIT]

I added the (commented) lines of the question that was indicated as a duplicate, but it is looped:

  

This webpage has a redirect loop

    
asked by anonymous 23.01.2017 / 13:29

1 answer

0

I discovered a way to do in SOen that solved my problem, not quite a answer to what I asked, but it is the solution of the problem, which is basically to use the lines that were suggested to me in the comments in a configuration file of amazon as we can see in this answer .

In summary of the answer, just put a .config directory in the% / a> the following:

files:
    "/etc/httpd/conf.d/ssl_rewrite.conf":
        mode: "000644"
        owner: root
        group: root
        content: |
            RewriteEngine On
            <If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
            RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
            </If>

That when deploying the application adds this rule to Apache's Elastic Beanstalk.

    
27.01.2017 / 17:02