I want all to force redirect to https but not on a specific page currently i have this .htaccess file:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
I want all to redirect to https but force http on a specific page: /exchage
What code do I need to put on my .htaccess file to achieve this function? Thanks.
What about adding another condition to the HTTPS redirect to check that the path doesn't start with exchange
? (I assume you misspelled exchage)
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/exchange
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} ^/exchange
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
Once you have updated your .htaccess file, please restart your browser. Otherwise it might force https if it has previously seen the URL use https.
I solve the problem with this code.
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/exchange
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /exchange
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
took me almost 3 hours just to come out with this code.