mod_pagespeed not obeying .htaccess

1268 views
Skip to first unread message

DoubleSpeed

unread,
Jun 24, 2015, 9:33:04 AM6/24/15
to mod-pagesp...@googlegroups.com
We have mod_pagespeed workinf fine however it is not obeying directives in the sites .htaccess file we have several ModPagespeedDisallow for folders which get ignored so also tried setting ModPagespeed off altogether however it remains on, can anyone advise why this behaviour would be occurring?

DoubleSpeed

unread,
Jun 25, 2015, 4:25:42 AM6/25/15
to mod-pagesp...@googlegroups.com
Hi Guys!

Anyone got any ideas on this please?

Joshua Marantz

unread,
Jun 25, 2015, 9:45:47 AM6/25/15
to mod-pagespeed-discuss
Do you have this in your conf file, which turns on htaccess processing?
   AllowOverride All

Or are you in a shared hosting environment where you can't read/write the conf files, but there is some kind of GUI control-panel button to turn on PageSpeed?

-Josh

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/7f834163-662e-4621-aa47-496688378333%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jeff Kaufman

unread,
Jun 25, 2015, 10:00:30 AM6/25/15
to mod-pagespeed-discuss

DoubleSpeed

unread,
Jun 25, 2015, 10:00:32 AM6/25/15
to mod-pagesp...@googlegroups.com
Hi Josh,

Thanks for replying, yes have AllowOverride controls for .htaccess set to AllowOverride All in the servers httpd.conf file I manually installed mod_page speed from command line, it is working just can control for the host using its htaccess file (note other elements in htaccess are beign obeyed by server e.g. rewrite engine on for example this work fine).

I have other servers where all works as it should i.e. can control at host level using htaccess just this particular installation isn't!?

Kind Regards,

Chris


On Thursday, 25 June 2015 14:45:47 UTC+1, jmarantz wrote:
Do you have this in your conf file, which turns on htaccess processing?
   AllowOverride All

Or are you in a shared hosting environment where you can't read/write the conf files, but there is some kind of GUI control-panel button to turn on PageSpeed?

-Josh
On Thu, Jun 25, 2015 at 4:25 AM, DoubleSpeed <chris.ne...@gmail.com> wrote:
Hi Guys!

Anyone got any ideas on this please?

On Wednesday, 24 June 2015 14:33:04 UTC+1, DoubleSpeed wrote:
We have mod_pagespeed workinf fine however it is not obeying directives in the sites .htaccess file we have several ModPagespeedDisallow for folders which get ignored so also tried setting ModPagespeed off altogether however it remains on, can anyone advise why this behaviour would be occurring?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+

Jeff Kaufman

unread,
Jun 25, 2015, 10:06:46 AM6/25/15
to mod-pagespeed-discuss
Could you paste your .htaccess files?

On Thu, Jun 25, 2015 at 10:00 AM, DoubleSpeed
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/8b2fd958-a5ff-4953-8ddc-735d6859c022%40googlegroups.com.
Message has been deleted

DoubleSpeed

unread,
Jun 25, 2015, 10:12:42 AM6/25/15
to mod-pagesp...@googlegroups.com
RewriteEngine on

<IfModule pagespeed_module>
   ModPagespeed off
      # using commands,filters etc
   ModPagespeedEnableFilters extend_cache
   ModPagespeedEnableFilters collapse_whitespace
   ModPagespeedEnableFilters rewrite_images
   ModPagespeedEnableFilters insert_image_dimensions
   ModPagespeedEnableFilters recompress_jpeg
   ModPagespeedImageRecompressionQuality -1
   ModPagespeedEnableFilters convert_gif_to_png
   ModPagespeedEnableFilters jpeg_subsampling
   ModPagespeedEnableFilters rewrite_css,sprite_images
   ModPagespeedEnableFilters remove_comments
   ModPagespeedDisallow "*/osb/*"
   ModPagespeedDisallow "*/crm/*"
   ModPagespeedDisallow "*/config/*"
</IfModule>

## Canonical redirect www to non-www
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]

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

#### SEO URL REWRITING ####
RewriteCond %{REQUEST_URI} !^(.*)\.(.*)$
RewriteCond %{REQUEST_URI} !^/config/(.*)$
RewriteCond %{REQUEST_URI} !^/phpMyAdmin/(.*)$
RewriteRule ^(.+)$ url_rewriter.php/$1 [NC]
> email to mod-pagespeed-discuss+unsub...@googlegroups.com.

DoubleSpeed

unread,
Jul 2, 2015, 10:20:27 AM7/2/15
to mod-pagesp...@googlegroups.com
Hi,

Anyone got any thoughts on this, it's still an issue and I've just found this same issue is happening on a separate server as well so not just limited to one installation?


On Wednesday, 24 June 2015 14:33:04 UTC+1, DoubleSpeed wrote:
We have mod_pagespeed working fine however it is not obeying directives in the sites .htaccess file we have several ModPagespeedDisallow for folders which get ignored so also tried setting ModPagespeed off altogether however it remains on, can anyone advise why this behaviour would be occurring?

Steve West

unread,
Jul 2, 2015, 9:17:12 PM7/2/15
to mod-pagesp...@googlegroups.com
Hi,

I've been testing this on 5 test servers and on 1 of them, it seems like a similar issue happens for some of the virtualhosts. The only solution is to manually purge entire /var/cache/mod_pagespeed/ and then reload apache. Still trying to isolate what's causing it. We too use .htaccess to activate PS. We're running v1.9.32.3-4448 so not sure if u are seeing that in the same version.

SW

DoubleSpeed

unread,
Jul 3, 2015, 2:12:34 AM7/3/15
to mod-pagesp...@googlegroups.com

Hi Steve,

Glad I'm not the only one seeing this!! Both my affected servers are running X-Mod-Pagespeed: 1.9.32.4-7251 - I've just tried setting mod_pagespeed to off then clearing the mod_pagespeed cache using su -c "touch /var/cache/mod_pagespeed/cache.flush" and restarting Apache however it remains on for the V host concerned - doh!

Any other ideas would be greatly appreciated?

Regards,

Chris

DoubleSpeed

unread,
Jul 6, 2015, 6:10:28 AM7/6/15
to mod-pagesp...@googlegroups.com
Just wondering if anyone has any thoughts on this, can't even turn off mod_pagespeed for the host using .htaccess doesn't obey any filters etc?

Julian Matz

unread,
Mar 11, 2016, 6:54:55 AM3/11/16
to mod-pagespeed-discuss
I'm having the same problem on Debian 8 with Apache 2.4.10.

Other .htaccess directives are working fine. To test, I added just the following lines to my .htaccess files:

ModPagespeed off
ModPagespeedModifyCachingHeaders off

However, when I view the HTTP headers, I still see the header:

X-Mod-Pagespeed:·1.9.32.13-0

I also tried adding these to my VirtualHost config. Same problem. ModPagespeed can only be turned of in /etc/apache2/mods-enabled/pagespeed.conf but then, it cannot be turned on in .htaccess  or vhost conf.

Is it a bug? Any solutions?

On Wednesday, 24 June 2015 14:33:04 UTC+1, DoubleSpeed wrote:

Jeff Kaufman

unread,
Mar 11, 2016, 11:02:22 AM3/11/16
to mod-pagespeed-discuss
On Fri, Mar 11, 2016 at 6:54 AM, Julian Matz <julia...@netlink.ie> wrote:
> I'm having the same problem on Debian 8 with Apache 2.4.10.
>
> Other .htaccess directives are working fine. To test, I added just the
> following lines to my .htaccess files:
>
> ModPagespeed off
> ModPagespeedModifyCachingHeaders off
>
> However, when I view the HTTP headers, I still see the header:
>
> X-Mod-Pagespeed:·1.9.32.13-0
>
> I also tried adding these to my VirtualHost config. Same problem.
> ModPagespeed can only be turned of in
> /etc/apache2/mods-enabled/pagespeed.conf but then, it cannot be turned on in
> .htaccess or vhost conf.
>
> Is it a bug? Any solutions?
>

Here's what's supposed to happen, and what I see happening on modpagespeed.com:

$ cat mps-on/index.html
<h1> Foo </h1>

<h2> Bar </h2>

$ cat mps-on/.htaccess
ModPagespeedEnableFilters collapse_whitespace

$ curl -D- www.modpagespeed.com/jefftk/mps-on/
HTTP/1.1 200 OK
Date: Fri, 11 Mar 2016 15:55:10 GMT
Server: Apache/2.4.7 (Ubuntu)
Accept-Ranges: bytes
X-Mod-Pagespeed: 1.10.33.5-0
Cache-Control: max-age=0, no-cache
Content-Length: 38
Content-Type: text/html

<head/><h1> Foo </h1>
<h2> Bar </h2>

And then with PageSpeed off:

$ cat mps-off/index.html
<h1> Foo </h1>

<h2> Bar </h2>

$ cat mps-off/.htaccess
ModPagespeedEnableFilters collapse_whitespace
ModPagespeed off

$ curl -D- www.modpagespeed.com/jefftk/mps-off/
HTTP/1.1 200 OK
Date: Fri, 11 Mar 2016 15:55:13 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Fri, 11 Mar 2016 15:54:58 GMT
ETag: "30-52dc7f3fcffe4"
Accept-Ranges: bytes
Content-Length: 48
Content-Type: text/html

<h1> Foo </h1>

<h2> Bar </h2>

You can see that when the .htaccess file says "ModPagespeed off" then
PageSpeed doesn't run and so doesn't insert the X-Mod-Pagespeed header
or remove the whitespace.

Could you send me your .htaccess file? Directly to jef...@google.com
if you're not up for posting it publicly?

Jeff

Julian Matz

unread,
Mar 12, 2016, 1:09:01 AM3/12/16
to mod-pagesp...@googlegroups.com
Hey, Jeff!

Right! I've done this test, analyzing the HTTP headers, and others using Google Pagespeed Insights. It just looks like my .htaccess statements are just ignored.

I tested it using the following .htaccess file in /test/ ( http://example.com/test/ ):

RewriteEngine on
RewriteBase /test/
RewriteRule ^index.php$ test.php [L]

ModPagespeed off
ModPagespeedModifyCachingHeaders off

The contents of the test/ directory are:

.htaccess
index.php (content "index")
test.php (content "test")

The redirect from index.php to test.php works. I can test this in my browser.

I then use the following command to get the headers:

wget --server-response --spider http://example.com/test/

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Sat, 12 Mar 2016 06:07:07 GMT
  Server: Apache
  Vary: Accept-Encoding
  X-Mod-Pagespeed: 1.9.32.13-0
  Cache-Control: max-age=0, no-cache
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=UTF-8
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.



--
You received this message because you are subscribed to a topic in the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mod-pagespeed-discuss/CM54IbhaiW4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAMJ6YUu%3DoUR7_m%2BmRRdViE8OKgq6yyH%2Buxv5iySEt3-nftwTuA%40mail.gmail.com.

Julian Matz

unread,
Mar 12, 2016, 1:38:51 AM3/12/16
to mod-pagesp...@googlegroups.com
Strangely, I have the exact same problem on a separate CentOS 6.7 server. Using the exact same test methods, but with Apache 2.4 instead of Apache 2.2.

So, I decided to install the Pagespeed beta version ( X-Mod-Pagespeed: 1.10.33.5-0 ). I first purged the stable module, including its config files, cache directories and log files, but it's the exact same thing. I still get the X-Mod-Pagespeed headers.

DoubleSpeed

unread,
Mar 12, 2016, 1:39:31 AM3/12/16
to mod-pagespeed-discuss
I still have this issue on a couple of servers what's strange is I have several servers where the .htaccess is obeyed on a per host basis and a couple of servers which ignore it, the servers basically all have the same set-up /configuration so not too sure how to troubleshoot this one!

To unsubscribe from this group and all its topics, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

Julian Matz

unread,
Mar 12, 2016, 1:41:32 AM3/12/16
to mod-pagespeed-discuss
@DoubleSpeed: Do you have the same version of Mod Pagespeed running on all of them?

DoubleSpeed

unread,
Mar 12, 2016, 1:44:08 AM3/12/16
to mod-pagespeed-discuss
I'm pretty sure that I do, however I'll double check and post back here to confirm

Julian Matz

unread,
Mar 12, 2016, 2:02:25 AM3/12/16
to mod-pagesp...@googlegroups.com
These are my loaded Apache modules (on the Debian 8 server):

$ apachectl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 fastcgi_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 headers_module (shared)
 mime_module (shared)
 mime_magic_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 pagespeed_module (shared)
 php5_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)

Julian Matz

unread,
Mar 12, 2016, 2:16:52 AM3/12/16
to mod-pagesp...@googlegroups.com
More troubleshooting info... I seem to have it working on a 3rd server, running Centos 5 and Apache 2.2. This one wasn't using Mod FastCGI, so I decided to disable FastCGI as well as all the vhosts on that server. I noew only have the default Apache index page. I am now able to turn Pagespeed off and on using .htaccess.

So, I'm wondering, could it be an issue with FastCGI?

DoubleSpeed

unread,
Mar 12, 2016, 2:52:43 AM3/12/16
to mod-pagespeed-discuss
Yes I think it is to do with the php applcaition/php version on the server and the execution mode!

Have just found that a site which was set to use CGI Wrapper as the execution mode when I changed to FCGId (run as virtual server owner) mod_pagespeed now obeys the .htaccess.

I'm now going to experiment with the other sites/servers which have this same issue to try and confirm.

Julian Matz

unread,
Mar 12, 2016, 3:06:23 AM3/12/16
to mod-pagesp...@googlegroups.com
It does indeed have something to do with PHP its server API model. I restored the server to exactly how it was before, but I swapped "index.php" and "test.php" with "index.html" and "test.html" and my .htaccess is now working with Mod Pagespeed.

So, it seems that if a request is made for a PHP file, Pagespeed statements are ignored in .htaccess, but if a request to a static HTML file is made, the .htaccess statements are obeyed.

If someone from the Pagespeed team could confirm this and give some insight, that'd be great.

--
You received this message because you are subscribed to a topic in the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mod-pagespeed-discuss/CM54IbhaiW4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/1b8897d7-9226-43db-8123-ac5d448cc1c9%40googlegroups.com.

Joshua Marantz

unread,
Mar 12, 2016, 5:47:06 PM3/12/16
to mod-pagespeed-discuss
I have to admit we are not experts in PHP, or the ways it is integrated into Apache.  It sounds like the answer lies in the PHP engine being integrated; it might be worth poking around the forums for that module to try to understand its impact on htaccess.

Out of curiosity, does it work to configure mod_pagespeed in <Directory> scopes even when it fails in .htaccess files?  If that's the case, it might be a case of the PHP module calling chdir or something?  Just a wild guess.

-Josh

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAHtPcCXGSgkk8u7-1RYw%3DgkM8Mfa_NzDWubqutjCj4dSmqU0Ow%40mail.gmail.com.

Julian Matz

unread,
Mar 12, 2016, 10:00:29 PM3/12/16
to mod-pagesp...@googlegroups.com
Hi Joshua,

It doesn't appear to work in <Directory> or <VirtualHost> directives either.

Alterego D

unread,
May 31, 2017, 11:45:03 AM5/31/17
to mod-pagespeed-discuss
Hi,

I've got the same problem.

I disabled pagespeed in .htaccess and in <Directory> scope. Pagespeed is still running. The only way to disable pagespeed is to insert "?PageSpeed=off" in the url.

I'm using Debian 8, Apache 2.4.10 with mod_php.

Other directives like adding filters are taken into consideration. The only line that does'nt work is "Modpagespeed off".

Any solution?
Reply all
Reply to author
Forward
0 new messages