Forum Moderators: phranque

Message Too Old, No Replies

mod deflate and sed combination doesn't work

How to rewrite with sed before using mod_deflate

         

ogerben

10:36 am on Dec 12, 2008 (gmt 0)

10+ Year Member



Hi,

I'm very new to apache filters.
I' trying to use as an external filter sed for rewriting internal links like:
s/index2.jsp?NAV=1426&LNG=DE/de\/haftungsausschluss\//gi

Afterwards I would like to gzip the content.
Zipping works fine and the sed is working great, but in combination it doesn't.

I believe I have to change the filtering order. But I don't know how.
I'm trying with ftype and it didn't resolve the problem. Perhaps I used the wrong syntax!?

Here is the part out of the httpd.conf I'm working with:
###########################
ExtFilterDefine helluxlink mode=output intype=text/html cmd="c:/Programme/GnuWin32/bin/sed.exe -f D:/cvs_data/hellux_home/regexp/replace.txt" ftype=10
ExtFilterDefine helluxlinkx mode=output intype=application/xml cmd="c:/Programme/GnuWin32/bin/sed.exe -f D:/cvs_data/hellux_home/regexp/replace.txt" ftype=10

<Location /hellux_home/>

# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter helluxlink;helluxlinkx

################ GZIP Content

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript

# 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¦swf¦pdf)$ no-gzip dont-vary

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

################ GZIP Content
</Location>
#######################

It would be great if someone could help me!
Thanks a lot in advance.

benjamin

jdMorgan

2:51 pm on Dec 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, the likely problem is that the content is being zipped first, so the text-rewriting filter cannot find the text that you want to rewrite.

Unfortunately, that's all I know about filters... :(

Jim

ogerben

3:25 pm on Dec 12, 2008 (gmt 0)

10+ Year Member



Yes, that's what I was guessing.
I found out that when placing the deflate statements into a .htaccess it works for all of the components which will be loaded on every page.
The html isn't gzipped but the rest of the stuff eg. .js and .css etc. So more or less 90 percent are zipped. It's better than nothing.
Perhaps there will be a better solution for me. I never give up :)
So if you have another one, please let me know.

Benjamin

jdMorgan

3:37 pm on Dec 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After reviewing the documentation [httpd.apache.org], it looks like you should consider using dynamic filtering if you are on Apache 2.1 or later, and use the FilterChain directive to set filter processing order.

Jim

ogerben

3:11 pm on Dec 15, 2008 (gmt 0)

10+ Year Member



Yep, sounds good to me. Unfortunately we are using 2.054 and I can't persuade our admin to upgrade. grrr.