Magento – Magento2 in windows IIS server – Pub/static appends version

magento2windows

I have installed magento2 in one of our windows server which uses IIS.

Followed the following blog, which helped for most part

http://blog.winhost.com/how-to-install-magento-2-1-2-on-winhost-iis/

I ran all the commands that is needed. Ran the main command as well

php bin/magento setup:static-content:deploy

However, when i run my application on browser. The css and js will return in 404 error. Here are the few files that gets loaded.

/pub/static/version1483704562/frontend/Magento/luma/en_US/mage/calendar.css Failed to load resource: the server responded with a status of 404 (Not Found)

pub/static/version1483704562/frontend/Magento/luma/en_US/mage/requirejs/mixins.js Failed to load resource: the server responded with a status of 404 (Not Found)

Here, if you notice. version1483704562 this version gets added up in URL. Not sure why this occur. The files are actually present, because of this version inclusion it throws error.

Please let me know on how to solve this. NOTE: Application is in windows IIS server

Best Answer

IIS convert static folder to Application and create web config file with following rule

        <rules>
            <rule name="Imported Rule 1-1" stopProcessing="true">
                <match url="^version.+?/(.+)$" ignoreCase="false" />
                <action type="Rewrite" url="{R:1}" />
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url=".*" ignoreCase="false" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="../static.php?resource={R:0}" appendQueryString="false" />
            </rule>