[FX.php List] [OFF] Rewrite for forcing http to https possible?

Troy Meyers tcmeyers at troymeyers.com
Tue Sep 23 10:23:26 MDT 2008


This has worked very well, and we've had the new SSL Mini running for a couple of days.

Only one issue has cropped up. Luckily it only affects some old and rare links that people have out there. It involves the rewrite rule that we have in the .htaccess file at the root level of the web stuff (the /Library/WebServer/Documents/.htaccess file).

The rule that causes http URLs to be converted to https URLs is this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Some other rules follow, but supposedly the L causes no further rules to be tried.

The problem is this...

While these examples work fine:

http://lab.troymeyers.com/
becomes
https://lab.troymeyers.com/

http://lab.troymeyers.com/flasking/listing.php?genus=Coryanthes
becomes
https://lab.troymeyers.com/flasking/listing.php?genus=Coryanthes

http://lab.troymeyers.com/flasking/file%20name%20with%20spaces.php
becomes
https://lab.troymeyers.com/flasking/file%20name%20with%20spaces.php


...this does NOT work well:
http://lab.troymeyers.com/flasking/listing.php?genus=Name%20with%20spaces
becomes
https://lab.troymeyers.com/flasking/listing.php?genus=Name%2520with%2520spaces

To clarify the problem, if the portion of a URL after the "?" has a character that seems like it ought to be encoded (if it weren't already URL encoded) it does it, even though it already IS encoded. Thus, the "%20" turns into "%2520". Note that is does NOT happen before the "?" character in the URL. In CDML-type URLs this produces missing field or file errors, since the names are messed up.

Any ideas how the RewriteRule should be changed to fix this?

-Troy



More information about the FX.php_List mailing list