Forum Moderators: phranque
So I have to work with a redirect to a script, if the client does not support compressed delivery
RewriteCond %{HTTP:accept-encoding} !gzip
RewriteRule .*.(htm¦js)$ http://example.com/cgi-bin/inflate.pl?file=$1 [r=307,L]
This should mean, if accept endoding !gzip
redirect all *.htm or *.js files
to a cgi script
the parameter file contains the part of the URL past the domain name
so
http://example.com/test/this.htm
should be redirected to
http://example.com/cgi-bin/inflate.pl?file=/test/this.htm
But something is maybe wrong with my .htaccess
It's difficult to test, so I use a server speed test
to find out, does it work or not.
Most server speed tests do not support compressed delivery.
So they are ideal to test.
As written, the value passed for "file=" would contain only the file extension "htm" or "js" because those are the only parts of the requested URL-path enclosed within the first set of parentheses. Try:
RewriteCond %{HTTP:Accept-Encoding} !gzip
RewriteRule ^(.+\.(htm¦js))$ http://example.com/cgi-bin/inflate.pl?file=$1 [R=307,L]
I also suggest that you do *not* feel at liberty to change the case on variables, directives, or flags until you know that the code works with proper casing.
Further, when you get this working, I'd suggest using an internal rewrite instead of a redirect. There is no reason to expose the "cgi-bin/inflate.php" filepath to the client -- browser or robot.
Replace the broken pipe "¦" character with a solid pipe character before use; Posting on this forum modifies the pipe characters.
Jim
Just tried [an on-line page analyzer]
But it seems, they do the request with
accept-encoding gzip
but they do not inflate the compressed delivered file
Header size = 184 bytes
Congratulations! This file was compressed.
View a formatted version of this HTML file, no files reported, loaded by the html file.
HTTP/1.1 200 OK
Date: Tue, 31 Mar 2009 18:32:52 GMT
Server: Apache/1.3.33 (Unix) FrontPage/5.0.2.2635
Transfer-Encoding: chunked
Content-Type: text/html
Content-Encoding: gzip
Seems I have to visit tomorrow an office in Salzburg country government. They have an internet connection with no gzip compression possible.
Somebody there told me last thursday, that visiting my web site looks like to open a zip file in the browser :)
[edited by: jdMorgan at 7:42 pm (utc) on Mar. 31, 2009]
[edit reason] No URLs, please. See Terms of Service, [/edit]