1

How can I (with a htaccess file) redirect a page that looks like this:

http://www.domain/page/?var=test&var2=test2

To something that looks like this:

 https://domain/page/?var=test&var2=test2

But do it so it only affects this page and nothing else?

matt
  • 2,252
  • 5
  • 29
  • 54
  • possible duplicate of [htaccess redirect to https://www](http://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) – xero Mar 12 '14 at 16:20

3 Answers3

0

This is very similar to this question. You want something like this:

# Redirect all HTTP traffic to HTTPS, but only if the requested page is /page
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^page/?$
RewriteRule ^(.*)$ https://domain.com/$1 [QSA]
Community
  • 1
  • 1
elixenide
  • 43,445
  • 14
  • 72
  • 97
0

You need an [OR] between 2 rewrite conditions:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(page(?:/.*)?)$ https://domain.com/$1 [L,R=301,NE]

This will redirect to https://domain.com if HTTPS is off OR else if your host name is www.

anubhava
  • 713,503
  • 59
  • 514
  • 593
0

Try this one

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Nurdin
  • 22,198
  • 39
  • 124
  • 293