Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess and gzipping issue?

Status
Not open for further replies.

marco28

Programmer
Sep 12, 2008
4
0
0
CA
Hi all

I'm new to the forum, but need some help regarding serving previously gzipped files. I need to gzip the files prior to serving, and not by the server.

So, i manually gzip the file, and my .htaccess looks like...

RewriteEngine on

AddEncoding x-gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]

On one website, this works just fine. But on my localmachine, and a 2nd website, this doesn't work.

All 3 sites run apache(different servers). Mod_rewrite is enabled on all 3.

All 3 servers serve up the filename.js.gz, but only one actually works, and has the browser unzip it. On the other 2, the browser receives filename.js.gz, renames it to filename.js, and can't use it cause its not unzipped.

Why would this happen? any ideas?

Thanks all

marco
 
My guess is that you do not have the same mime type definitions between the servers for those file extensions... check httpd.conf

D.E.R. Management - IT Project Management Consulting
 
See if the fileinfo override is set for those directories (I believe Rewrites and Addencoding are both type FileInfo.

If you don't have access to the config, just put some garbage in .htaccess or some known rewrite rule.
 
Thanks for the response, but i'm still having this problem. I do have access to my httpd.conf for my local server ( an xampplite installation).

so #1, what mime type definitions do i need? javascript and gzip? I have those.

and #2 "fileinfo override is set for those directories"

i have

Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all

set for my localhost.

I am running a virtual host. I will try removing my virtual hosts.

Any more ideas, or am i missing something?

So to be clear, the files are being served, but not being unzipped

the response shown in the 'Charles Utility' is

HTTP/1.1 304 Not Modified
Date Sat, 13 Sep 2008 13:07:40 GMT
Server Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8h mod_autoindex_color PHP/5.2.6
ETag "1100000002a1fe-79-456c5d692f486"

Thanks all

Marco
 
hold on!

I was playing with my virtual hosts and get this error message
"... AllowOverride not allowed here..."

in my localhost virtual host

<VirtualHost 127.0.0.1>
DocumentRoot "C:\xampplite\htdocs"
ServerName localhost

AllowOverride All


#Choose: debug, info, notice, warn, error, crit, alert, emerg
LogLevel info
ErrorLog C:\xampplite\htdocs\logs\impact-error.log
CustomLog C:\xampplite\htdocs\logs\impact-access.log combined
</VirtualHost>

does this help?

marco
 
Hi all

I've found the solution

i had to add

RemoveType application/x-gzip .gz .tgz

to the top of my .htaccess file or comment out the

AddType application/x-gzip .gz .tgz

from my httpd.conf

thanks to those who helped.

Marco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top