2

How can exclude some directory for mod_pagespeed using htaccess rules....

note : I am required to disable only some directory not all files and folders

Me7888
  • 1,191
  • 4
  • 17
  • 19

2 Answers2

8

You can simply set ModPagespeed off in an .htaccess file. This will disable all rewiting of HTML in that directory. It will not stop mod_pagespeed from rewriting images/CSS/JS in that directory.

To disable rewriting of all HTML and resources, you can add ModPagespeedDisallow http://www.example.com/subdir/* anywhere in your config. See documentation for more info. Note that this requires you to specify the entire URL, not just a relative path.

sligocki
  • 6,246
  • 5
  • 38
  • 47
  • Actually you can use wildcards now like ModPagespeedDisallow "*/images/captcha/*" - from https://developers.google.com/speed/pagespeed/module/restricting_urls – Phill Price Mar 31 '15 at 08:35
  • Just loosing my words to say thanks to @sligocki ... Just saved my day with the simple answer.. – Sahasrangshu Guha Apr 16 '15 at 10:08
0

In your .htaccess file (in the directory you want to disable), put the following lines:

<IfModule pagespeed_module>
    ModPagespeed off
</IfModule>

That will disable it for that directory only and will prevent errors when there's no pagespeed module enabled on the webserver.

Francisco Zarabozo
  • 3,676
  • 2
  • 28
  • 54