Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] [edited by: engine at 5:19 pm (utc) on Oct 17, 2016]
[edit reason] please use example.com [/edit]
I have 2 rules in my htaccess that
- force the use of www. in front of domain name
- redirect all urls from http to https
My problem is that I have 1 page that must be opened in http only, and never in https
How could I get that?
RewriteEngine On
# redirect requests for https://www.example.com/this-page to http://www.example.com/this-page
RewriteCond %{HTTPS} =on
RewriteRule ^this-page$ http://www.example.com/this-page [R=301,L]
# redirect requests for http://example.com/this-page to http://www.example.com/this-page
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^this-page$ http://www.example.com/this-page [R=301,L]
# redirect requests for all URIs hosted on example.com except for this-page to the requested URI on https://www.example.com/
RewriteCond %{REQUEST_URI} !^this-page$
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# redirect requests for all URIs hosted on http: protocol except for this-page to the requested URI on https://www.example.com/
RewriteCond %{REQUEST_URI} !^this-page$
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteEngine On
# redirect requests for https://www.example.com/siti-consigliati.php to http://www.example.com/siti-consigliati.php
RewriteCond %{HTTPS} =on
RewriteRule ^siti-consigliati.php$ http://www.example.com/siti-consigliati.php [R=301,L]
# redirect requests for http://example.com/siti-consigliati.php to http://www.example.com/siti-consigliati.php
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^siti-consigliati.php$ http://www.example.com/siti-consigliati.php [R=301,L]
# redirect requests for all URIs hosted on example.com except for siti-consigliati.php to the requested URI on https://www.example.com/
RewriteCond %{REQUEST_URI} !^siti-consigliati.php$
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# redirect requests for all URIs hosted on http: protocol except for siti-consigliati.php to the requested URI on https://www.example.com/
RewriteCond %{REQUEST_URI} !^siti-consigliati.php$
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] [edited by: engine at 9:13 pm (utc) on Nov 16, 2016]
[edit reason] Please use example.com [/edit]
RewriteCond {HTTP_HOST} !^(www\.example\.it)?$ [OR]
RewriteCond %{HTTPS} on
RewriteRule ^siti-consigliati\.php http://www.example.it/siti-consigliati\.php
RewriteCond {REQUEST_URI} !^siti-consigliati\.php$
RewriteCond {HTTP_HOST} !^www\.example\.it)?$ [OR]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.example.it/$1 [L,R=301]