Issue
I want the user to redirect to https
except specific URL
pattern.
For example, if User types sacyolo.com
, I want him to redirect to `href="https://sacyolo.com" rel="nofollow">https://sacyolo.com
But when user types sacyolo.com/api/....,`
I don't want him to redirect to https.
I tried
RewriteCond %{HTTP_HOST} ^sacyolo.com$ [NC]
RewriteCond %{REQUEST_URI} !^/api(.*)$ [NC]
RewriteRule ^(.*)$ https://sacyolo.com/$1 [R=301,L]
But it doesnt work.
Solution
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^sacyolo.com$
RewriteCond %{REQUEST_URI} !^/api(.*)$
RewriteRule ^(.*)$ https://sacyolo.com/$1 [R=301,L]
Put this code in the .htaccess file at root folder.
Answered By - Rijul Sudhir Answer Checked By - David Marino (WPSolving Volunteer)