<p>I setup phpMyID on one of my machines, and I'm trying to get apache to redirect to HTTPS only when a password is being submitted.  I am doing this as my original setup of redirecting all openid traffic didn't work stackoverflow doesn't like my self signed certificate.  This is the new rule I've written, but its not working:</p>

<pre><code>RewriteRule http://%{SERVER_NAME}/openid/index.php(\?.+)$ https://%{SERVER_NAME}/openid/index.php$1
</code></pre>

You need to use a Cond to test for both port (http or httpd) and query string:
```
```
RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} (.+)
RewriteRule /openid/index.php https://%{SERVER_NAME}/openid/index.php?%1
```
```
if on .htaccess you must use instead
```
```
RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} (.+)
RewriteRule openid/index.php https://%{SERVER_NAME}/openid/index.php?%1
```
```