This is how you can force your whole site to use HTTPS, except for one page. This will do a 301 redirect to HTTPS on all pages of your site, except for the one URL that you will specify. This allows you to keep one URL on HTTP, for whatever reason that you may need.
These are rewrite rules for the .htaccess
file which resides on your server.
In this example, the page URL that is going to be forced to use HTTP is your-page-url/
. The rest of the pages on the site will be forced to use HTTPS. Be sure to change your-page-url/
to your own URL that you want to force to use HTTP on your site. The first slash (/
) immediately in front of your-page-url/
must remain there. However, the slash at the end of your-page-url/
is not required. Only include the ending slash if your own URL has an ending slash.
RewriteEngine On # Go to https if not on /your-page-url/ RewriteCond %{SERVER_PORT} =80 RewriteCond %{THE_REQUEST} !/your-page-url/ [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Go to http if on /your-page-url/ RewriteCond %{SERVER_PORT} !=80 RewriteCond %{THE_REQUEST} /your-page-url/ [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Mauricio
December 3rd, 2016 at 1:31 pm
I added the code as you commented, but is not working.
Every time that I go to the page where I want to have http is redirecting me to https
RewriteEngine On
# Go to https if not on /your-page-url/
RewriteCond %{SERVER_PORT} =80
RewriteCond %{THE_REQUEST} !/content.php?id=81 [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Go to http if on /your-page-url/
RewriteCond %{SERVER_PORT} !=80
RewriteCond %{THE_REQUEST} /content.php?id=81 [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]