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

Asked

Viewed 498 times

1

I have a Mac store that is configured to use https on the front. But I need a directory to force the use of http.

How can I do that? I tried using the following in htaccess:

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

1 answer

2


Your . htaccess seems to be redirecting from http to http anyway, there must be infinite directions due to this RewriteCond %{HTTPS} off.

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

You can create this directly on 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]

Like the RewriteCond already check maybe you can simplify 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]

How do I explain in /a/188963/3635, so if you need to rename the folder you won’t need to RewriteRule just adjust the RewriteCond.

Note: [R] is different from [R=301], the R is equivalent to a temporary direction and the R=301 is permanent redirection, this may affect searchers like Google that indexes your site.

  • 1

    Thank you!! I thought q was not going, but it is because of the same Amazon, the /Folder actually stays inside other folders, despite being accessed example.com/Folder

  • @good cpbox, managed to discover alone, congratulations!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.