I am using htaccess to redirect certain pages to htaccess. The code am using is
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /core/marketing/editprofile
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
The page is redirecting for/core/marketing/editprofile, but it is not redirecting back to http for other pages after this.
Please tell me hos can i enable https to http redirection also?
You must do the reverse for other pages:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /core/marketing/editprofile
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !/core/marketing/editprofile
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Related
I have site with https
But I need specific folder should be http.
How can we achieve it ?
e.g.
my site is
https://www.mywebsite.com
I want folder1/subfolder1 should be forced to http://
e.g. http://www.mywebsite.com/folder1/subfolder1
I searched on net...but maximum search show how to force http to https
I tried .htaccess as follows :
try 1.
RewriteRule ^(/folder1/subfolder1)($|/) - [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
try 2.
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folder1/subfolder1
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But it didn't work..
You can use these rules in your site root .htaccess:
RewriteEngine On
# force https on everything except /folder1/subfolder1
RewriteCond %{THE_REQUEST} !\s/+folder1/subfolder1[/?\s] [NC]
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
# force http on /folder1/subfolder1
RewriteCond %{THE_REQUEST} \s/+folder1/subfolder1[/?\s] [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
Make sure to clear your browser cache or use a new browser for testing.
I would like to redirect all my website from http tp https except on some pages:
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ex: pages to be excluded :
/home /user /info /mydata /ajax.php
Add yet another RewriteCond directive:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(home|user|info|myta|ajax\.php)
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
or in a single rule:
RewriteCond %{HTTPS} off
RewriteRule ^/?(?!home|user|info|myta|ajax\.php) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I want to remove secure http only for a certain url:
https://www.example.com/car-sharing.html
supposed to redirect to
http://www.example.com/car-sharing.html
I tried several .htaccess directives, for example
RewriteCond %{HTTPS} on
RewriteCond $1 ^(car-sharing\.html)
RewriteRule (.*) http://%{HTTP_HOST}%$1 [R=301,L]
or
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} car-sharing.html
RewriteRule ^(.*)$ http://www.example.com/%{REQUEST_URI} [R=301,L]
but I can't get it to work, the redirect from https to http never happens. Any help is much appreciated.
%{REQUEST_URI} includes the leading slash, so this should work:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/car-sharing.html
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L,QSA]
We have server having 2 domains
1) exmaple.co
2) exmaple.com.au
If User hits first domain "example.co"
http://www.exmaple.co OR http://exmaple.co then it should be redirect to
https://exmaple.co
If User hits second domain "example.com.au"
http://www.exmaple.com.au OR http://exmaple.com.au then it should be
redirect to
https://exmaple.com.au
We have purchase SSL.
We have use framework Codeigniter set the coding in htaccess.
RewriteCond %{HTTP_HOST} ^exmaple.co [NC]
RewriteRule ^(.*)$ http://exmaple.co/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^exmaple.com.au [NC]
RewriteRule ^(.*)$ http://www.exmaple.com.au/$1 [L,R=301]
If i use above code then it's goes on redirect loop.
You are getting infinite redirect loop because you are not preventing the redirect to happen at all.
To achieve what you are trying to do:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co$
RewriteRule ^(.*)$ https://example.co/$1 [L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com\.au$
RewriteRule ^(.*)$ https://example.com.au/$1 [L]
Try :
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.(example\.com\.au|example\.co)$
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R]
This rule will redirect :
http://example.co
http://www.example.co
https://www.example.co
or
http://example.com.au
http://www.example.com.au
https://www.example.com.au
to https non-www
I use this redirection code in .htaccess to force all address use https :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://Domain.com%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^www.Domain.com [NC]
RewriteRule (.*) https://Domain.com%{REQUEST_URI} [L,R=301,NC]
I want a solution to force just one page like domain.com/example to use http only and not forced to https .
How i can modify the redirection code ?
Thanks alot
To exclule a page from the https redirection, you can use :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/example
RewriteRule (.*) https://Domain.com%{REQUEST_URI} [L,R=301,NC]