V
V
vasilseodor2017-09-12 11:38:13
htaccess
vasilseodor, 2017-09-12 11:38:13

How to redirect from http to https for a specific folder?

I have a site in php. The site has a lot of directories - folders and just php files. How to make the whole site redirect to https, but only except for one goods folder and all the files and folders attached to it?
I tried that, but it still redirects to https

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteCond %{HTTP_HOST} ^goods [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kornilov, 2017-09-12
@KorniloFF

RewriteCond %{REQUEST_FILENAME} goods/ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^site\.ru
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]

Try something like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question