0

I want to make mod_deflate working on my website. All works fine: for the css, js etc files, mod_deflate is working. When I go to host/city/, it also works fine. But when I call host/city it doesn't work. But I want to use the uri without trailing slash.

The project is running on the Symfony2 framework.

I get this Response headers (on host/city):

HTTP/1.1 200 OK
Date: Tue, 13 May 2014 06:14:08 GMT
Server: Apache
Cache-Control: no-cache
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

And these for on host/city/:

Cache-Control:no-cache, max-age=21600
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Tue, 13 May 2014 06:16:58 GMT
Expires:Tue, 13 May 2014 12:16:58 GMT
Keep-Alive:timeout=15, max=100
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding

I use the following .htaccess:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 5 minutes"
ExpiresByType image/ico "access plus 8 days"
ExpiresByType text/html "access plus 6 hours"
ExpiresByType image/jpg "access plus 8 days"
ExpiresByType image/jpeg "access plus 8 days"
ExpiresByType image/gif "access plus 8 days"
ExpiresByType image/png "access plus 8 days"
ExpiresByType application/x-javascript "access plus 8 days"
ExpiresByType text/javascript "access plus 8 days"
ExpiresByType application/javascript "access plus 8 days"
ExpiresByType text/css "access plus 8 days"
ExpiresByType text/xml "access plus 2 days"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On

#<IfModule mod_vhost_alias.c>
    RewriteBase /
#</IfModule>

RewriteCond %{HTTP_HOST} ^(www\.)?otherwebsite\.com [NC]
#RewriteCond %{REQUEST_URI} !^/app/(.*)
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{QUERY_STRING} !.*\is_app=([^&]*).*
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301]

RewriteRule ^mywebsite/(.*)$ /$1 [L,R=301]

RewriteRule ^mywebsite http://www.mywebsite.com [L,R=301]

# Remove trailing slash of URLs except for .../app/
RewriteCond %{REQUEST_URI} !^.*app/$
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=303,P]

# redirect requests without any subdomain to www.
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]


</IfModule>

Any idea? Thank you very much!

Nico
  • 39
  • 3
  • If I remove the line `RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=303,P]`, the compression for host/city/ is not working, too. – Nico May 13 '14 at 09:03
  • I think the server was misconfigurated. After changing to a new server, the problem was solved... – Nico Jun 05 '14 at 19:00

0 Answers0