Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheBusting rewrite rule is missing file exists check #22

Closed
unger opened this issue May 24, 2015 · 1 comment
Closed

CacheBusting rewrite rule is missing file exists check #22

unger opened this issue May 24, 2015 · 1 comment
Assignees
Milestone

Comments

@unger
Copy link

unger commented May 24, 2015

The .htaccess version of this rewrite rule contains a check that the requested file does not exist before rewriting (the !-f part in RewriteCond %{REQUEST_FILENAME} !-f).

This check is needed to avoid rewriting if the file exists on the server. Otherwise it will return 404, example below.
jquery-1.11.3.js => jquery-1.11.js

This can be solved by using a condition of the rewiterule, full example below:

<rewrite>
    <rules>
        <rule name="Cachebusting">
            <match url="^(.+)\.\d+(\.(js|css|png|jpg|gif)$)" />
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            </conditions>
            <action type="Rewrite" url="{R:1}{R:2}" />
        </rule>
    </rules>
</rewrite>
@ChrisMcKee
Copy link
Member

Thanks i'll add that in.

@h5bp h5bp locked and limited conversation to collaborators May 25, 2015
@ChrisMcKee ChrisMcKee self-assigned this Nov 16, 2015
@ChrisMcKee ChrisMcKee modified the milestone: v3.0 Nov 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants