Search code examples
javascriptmod-pagespeed

Internal links being changed by mod_pagespeed


I noticed that when using mod_pagespeed on my site it updates my internal links.

When I am on / then my navigation looks like:

<ul>
    <li><a href="foo/bar"></a></li>
    <li><a href="example"></a></li>
</ul>

But when I am on /foo the same navigation looks like:

<ul>
    <li><a href="bar"></a></li>
    <li><a href="/example"></a></li>
</ul>

And when I am on /example it looks like:

<ul>
    <li><a href="/foo/bar"></a></li>
    <li><a href="example"></a></li>
</ul>

Is there a way to stop this behaviour as it's breaking some JS that relies on the href attribute of each link.


Solution

  • You can disable this feature by adding

    ModPagespeedDisableFilters trim_urls
    

    to your pagespeed.conf file. See https://developers.google.com/speed/docs/mod_pagespeed/filter-trim-urls for more details.