How to exclude a single page from htaccess rules?

1 replies
  • WEB DESIGN
  • |
Hi
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

RewriteEngine On
RewriteCond %{HTTP_HOST} ^terapiadicoppiabrescia.it [NC]
RewriteRule ^(.*)$ http://www.terapiadicoppiabrescia.it/$1 [L,R=301]

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

My problem is that I have 1 page that must be opened in http only, and never in https
How could I get that?

Thank you
#exclude #htaccess #page #rules #single
  • Profile picture of the author Patrick
    # Redirect Rules
    RewriteEngine On
    RewriteBase /

    # Redirect from non-www to www
    RewriteCond %{HTTP_HOST} ^terapiadicoppiabrescia.it [NC]
    RewriteRule ^(.*)$ http://www.terapiadicoppiabrescia.it/$1 [L,R=301]

    # force HTTPS for all except one page
    RewriteCond %{HTTPS} off
    RewriteCond %{THE_REQUEST} !/pagename/ [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # force HTTP for one page
    RewriteCond %{HTTPS} on
    RewriteCond %{THE_REQUEST} /pagename/ [NC]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    This should do it.

    Make sure you change the /pagename/ to the url slug of your page.
    {{ DiscussionBoard.errors[10884125].message }}

Trending Topics