Answer the question
In order to leave comments, you need to log in
How to make a rule for Apache to redirect from http to https except for a URL of a certain mask?
How to make a rule for Apache to redirect from http to https except for a URL of a certain mask?
It just so happened that api must work over http and https, and everything else only over https.
What is now:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !/api
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_URI} \.(css|jpg|gif|png|zip|rar|doc|xls|js|tif|tiff|docx|xlsx|ico)$
RewriteRule ^(.*)$ $1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pag=$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question