Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_rewrite mod_pagespeed RewriteCond

I have the following in my .htaccess file:

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

The server admin has installed Google mod_pagespeed and of course, because the folder doesn't exist, it logs an error every time as it tries to access /mod_pagespeed_beacon (and no stats are logged).

What RewriteCond do I need to add (and where) so /mod_pagespeed_beacon will work?

like image 447
Darryl Hein Avatar asked Dec 09 '22 13:12

Darryl Hein


2 Answers

Found the answer to my question. Just add the following:

RewriteCond %{REQUEST_URI} !^/mod_pagespeed_beacon

I don't think it matters where in the list of rewrite conditions is goes.

-- Edit

I also needed the following to access the statistics:

RewriteCond %{REQUEST_URI} !^/mod_pagespeed_statistics
like image 75
Darryl Hein Avatar answered Dec 30 '22 03:12

Darryl Hein


More generally you can whitelist all resources with pagespeed in the name with:

RewriteCond %{REQUEST_URI} !pagespeed

See the new section in the mod_pagespeed FAQ

like image 20
sligocki Avatar answered Dec 30 '22 03:12

sligocki