Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite and mod_deflate

mod_rewrite and integration of caching via mod_deflate

         

givehimagun

3:29 am on Apr 15, 2006 (gmt 0)

10+ Year Member



I have mod_rewrite enabled to mask url (without redirection) to a page, but my mod_deflate does not correctly interpret the new urls as deflateable.

Here is my .htaccess:


RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.example\.net[/url] [NC]
RewriteRule ^(.*)$ http://www.example.net/$1 [R=301,L]

RewriteRule ^user/([A-Za-z0-9@._-]+)/?$ profile.php?username=$1 [L]
RewriteRule ^buddies/([A-Za-z0-9@._-]+)/?$ buddies.php?username=$1 [L]

The mod_deflate settings I use are straight from the Apache Manual and work on pages that are not in the mod_rewrite set:


<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif¦jpe?g¦png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

I tried doing some debugging, here are the results from the response headers.

http://www.example.net/phpinfo.php -> gzip encoded

[these next two are the same url in different forms]
www.example.net/user/givehimagun -> not encoded
www.example.net/profile.php?username=givehimagun -> gzip encoded

Online compression checkers report the same:
www.example.net/user/givehimagun -> not gziped
www.example.net/profile.php?username=givehimagun -> gziped
I tried messing with the <Location /> part of the mod_deflate but that just breaks things

If anyone could give me some help, I would greatly appreciate it. Thanks!

[edited by: jdMorgan at 2:11 am (utc) on April 16, 2006]
[edit reason] No URLS, please. See Terms of Service. [/edit]

givehimagun

3:03 am on Apr 17, 2006 (gmt 0)

10+ Year Member



So i tried a bunch of things to no avail.

One thing that is obvious is that the pages that do get compressed do not have the Transfer-encoding: Chunked header, while the ones without compression have that header.

I even forced a [R] flag on my mod_rewrite rules, but all that does is mask the problem by using the compressable (ultimately non-rewrote rules) to display, thus defeating the purpose of having nice rewrote urls.

I just don't get it...this thing is frustrating me.

I have FollowSymLinks if that matters, but I don't know what else could be affecting the rewrote urls and not affecting the others!

jdMorgan

12:56 pm on Apr 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How does the MIME-type header returned with a successfully-compressed file compare to that of a rewritten (non-compressed) one?

Jim