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,312
  • 5
  • 34
  • 57
  • 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
  • 44,308
  • 16
  • 74
  • 100
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
  • 761,203
  • 64
  • 569
  • 643
0

Try this one

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Nurdin
  • 23,382
  • 43
  • 130
  • 308