Tyler
Tyler

Reputation: 3813

W3 Total Cache IIS minify error

My Problem

I am getting an error trying to minify URLs using the Wordpress plugin W3 Total Cache with IIS.

W3 Total Cache error:It appears Minify URL rewriting is not working. Please verify that the server configuration allows .htaccess Unfortunately minification will not function without custom rewrite rules. Please ask your server administrator for assistance. Also refer to the install page for the rules for your server. Technical info

.htaccess file contains rules to rewrite url http://myurl.com/:\Web\Public_Test2/wp-content/cache/minify/000000/w3tc_rewrite_test. If handled by plugin, it returns "OK" message. The plugin made a request to http://myurl.com/:\Web\Public_Test2/wp-content/cache/minify/000000/w3tc_rewrite_test but received: Connection timed out after 2016 milliseconds instead of "OK" response.

(note: I edited the domain name for privacy) I find the URL to be quite odd having the domain in there but I do not know how to change the default URL it tests. If coming from the main directory it is indeed Web/Public_Test2/wp-content/cache/minify but there is no 000000 folder in there.

W3 Total Cache Recommendations

Under the install tab for the plugin there is a note for people not using apache:

In the case where Apache is not used, the .htaccess file located in the root directory of the WordPress installation, wp-content/w3tc/pgcache/.htaccess and wp-content/w3tc/min/.htaccess contain directives that must be manually created for your web server software.

However, a w3tc folder does not exist, only a w3tc-config folder which has a master.php and master-admin.php file, no .htaccess or subfolders. I checked a cache folder under wp-config and there is no .htaccess in any subfolder. So I am not sure how to change the web.config or with what directives.

My Attempt

I found somewhere suggesting that these rewrite rules be added to web.config, I added them but it did not change the error at all:

<rule name="w3tc_rewrite_test" stopProcessing="true">
    <match url="^wp-content/cache/minify/000000/w3tc_rewrite_test" />
    <action type="Rewrite" url="wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1" logRewrittenUrl="true" />
</rule>
<rule name="w3tc-minify-test-file" stopProcessing="true">
    <match url="wp-content/cache/minify/(.+/[X]+\.css)$"  />
    <action type="Rewrite" url="wp-content/plugins/w3-total-cache/pub/minify.php?test_file={R:1}"  />
</rule>
<rule name="w3tc-minify-file" stopProcessing="true">
    <match url="wp-content/cache/minify/(.+\.(css|js))$"  />
    <action type="Rewrite" url="wp-content/plugins/w3-total-cache/pub/minify.php?file={R:1}"  />
</rule>

Upvotes: 0

Views: 2457

Answers (1)

user985952
user985952

Reputation: 97

I ran into the same issue and here is the solution that worked for me:

W3 Total Cache: Version 0.9.4.1

Wordpress: Version 4.5.2

IIS: Version 7.5

Server: Windows 2008 R2

My web.config has these rules:

<rewrite>
  <rules>
            <clear />
            <rule name="w3tc-minify-file" stopProcessing="true">
                <match url="wp-content/cache/minify/(.+\.(css|js))$" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                <action type="Rewrite" url="wp-content/plugins/w3-total-cache/pub/minify.php?file={R:1}" />
            </rule>
            <rule name="wordpress" enabled="true" patternSyntax="Wildcard">
                <match url="*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php" />
            </rule>         
        </rules>
</rewrite>

When I put the w3tc-minify-file rule under my wordpress rule, it did not work and I was getting 404 errors on all of the minify files W3TC was creating.

I'm using manual mode minify and just combining my css and js files and it's working great. Hope it helps someone.

The chances of this working with the auto minify mode are very low, so I definitely recommend doing the manual mode for the highest chance of success. I had 3 JS files and 2 CSS files I could not combine/minify because they broke my site. Manual mode gives you the most control, so spend a bit of time adding each file until you have it as best as you can.

Upvotes: 1

Related Questions