[FX.php List] [OFF] Rewrite for forcing http to https possible?
Troy Meyers
tcmeyers at troymeyers.com
Tue Sep 23 20:38:55 MDT 2008
David,
Got it! At least I think I have.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,NE,L]
>From http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html ...
noescape|NE' (no URI escaping of output)
This flag prevents mod_rewrite from applying the usual URI escaping
rules to the result of a rewrite. Ordinarily, special characters
(such as '%', '$', ';', and so on) will be escaped into their hexcode
equivalents ('%25', '%24', and '%3B', respectively); this flag
prevents this from happening. This allows percent symbols to appear
in the output, as in
RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
which would turn '/foo/zed' into a safe request for
'/bar?arg=P1=zed'.
Now, when I put in:
http://lab.troymeyers.com/flasking/listing.php?genus=two%20names
it turns into:
https://lab.troymeyers.com/flasking/listing.php?genus=two%20names
Unless that messes something else up, I think that's the solution.
-Troy
> Hi Troy,
>
> In re-reading your original post I realized that what's happening is you
> are passing a URL with %20 to the rewrite engine and it's encoding the %
> again which results in %2520 ("%% " or "percent percent space") and
> that's why the URL fails.
>
> I'll think about it a bit more, but would you agree that is the actual
> problem? If it is, then the solution is maybe to have a rewritemap that
> handles this? Not sure, just thinking out loud.
>
> - David
More information about the FX.php_List
mailing list