R
R
reforket2017-07-06 19:02:41
htaccess
reforket, 2017-07-06 19:02:41

How to redirect from HTTP to HTTPS with exceptions in htaccess?

Good day!
There is a code in htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>

You need to add links to the exclusions:
http://example.com/?wc1c=exchange
http://example.com/wc1c/exchange/

Tried like this, but throws on the main page:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond  %{REQUEST_URI}  !^/wc1c/exchange/
RewriteCond  %{REQUEST_URI}  !^wc1c=exchange
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>

Can you please tell me how to write exceptions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-07-06
@reforket

RewriteCond %{SERVER_PORT} !^443$
RewriteCond  %{REQUEST_URI}  !^/wc1c/exchange/& [NC]
RewriteCond %{QUERY_STRING} !(^|&)wc1c\=exchange($|&) 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question