How to redirect only one directory to http instead of https?

1

I have a magento store that is set up to use https on the front. However I need a directory to force the use of http.

How can I do this? I tried to use the following in htaccess:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ http://example.com/folder/$1 [R,L]
    
asked by anonymous 24.05.2017 / 01:50

1 answer

2

Your .htaccess seems to be directing from http to http even, there must be infinite directives due to this RewriteCond %{HTTPS} off .

I also believe that folder should be /folder/ when compared to %{REQUEST_URI}

You can create this directly in rewriterule :

RewriteEngine On

# Verifica se esta em uma página https
RewriteCond %{HTTPS} on

# Verifica se o caminho esta vindo do path folder
RewriteCond %{REQUEST_URI} /folder/

# Pega o que vier depois de 'folder/'
RewriteRule ^folder/(.*)$ http://example.com/folder/$1 [R,L]

As RewriteCond already checks, maybe you can simplify it to:

RewriteEngine On

# Verifica se esta em uma página https
RewriteCond %{HTTPS} on

# Verifica se o caminho esta vindo do path folder
RewriteCond %{REQUEST_URI} /folder/

# Pega o que vier depois de 'folder/'
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

As I explained in link , so if you need to rename the folder you will not need to tweak RewriteRule just set RewriteCond .

  

Note: [R] is different from [R=301] , R is a temporary targeting and R=301 is permanent redirect, this can affect search engines like Google indexing your site.

    
24.05.2017 / 02:09