Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i need to create a rewrite rule to redirect my page from http://example.com to https://example.com.

But in the case that the client opened the page with any GET parameter, it should remain the same without any redirecting. For example:

  • http://example.com/index.php should redirect to https://example.com/index.php
  • http://example.com/index.php?param1=val1 should not redirect.
share|improve this question
1  
And the webserver is ? {apache|nginx|lighttpd|IIS|...} –  Julien Vehent Oct 10 '10 at 13:51

1 Answer 1

up vote 0 down vote accepted

Try:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^([^?]+)$
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R,L]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.