Sharing some useful tips, solutions and notes for Geeks.

Friday, September 1, 2017

redirect https to http for a certain file .htaccess

Today i needed to redirect for a specific URL to http only. Since whole site was loaded in https, i have done a lil bit scratch on my head to fix it.

At last i have found a solution for it and shared below.

       
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/test\.php$ [NC]
RewriteRule (.*) https://www.example.co.uk/$1 [L,R=301]
RewriteCond %{HTTPS} on
RewriteRule ^(test\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]


Do remember to change the domain(example) and the file name(if its other ext, do change the php to corresponding file name) and see how it goes.

Good luck!!!

No comments: