简体   繁体   English

W3 Total Cache IIS缩小错误

[英]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. 我在尝试使用带有IIS的Wordpress插件W3 Total Cache来缩小URL时遇到错误。

W3 Total Cache error:It appears Minify URL rewriting is not working. W3 Total Cache错误:似乎Minify URL重写不起作用。 Please verify that the server configuration allows .htaccess Unfortunately minification will not function without custom rewrite rules. 请验证服务器配置是否允许.htaccess不幸的是,如果没有自定义重写规则,缩小将无法进行。 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. .htaccess文件包含重写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. 该插件向http ://myurl.com/:\\ Web \\ Public_Test2 / wp-content / cache / minify / 000000 / w3tc_rewrite_test发出了请求,但收到消息:连接在2016毫秒后超时,而不是“确定”响应。

(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. (注意:为了保护隐私,我编辑了域名)我发现在其中存在该域名的URL很奇怪,但是我不知道如何更改它测试的默认URL。 If coming from the main directory it is indeed Web/Public_Test2/wp-content/cache/minify but there is no 000000 folder in there. 如果来自主目录,则确实为Web / Public_Test2 / wp-content / cache / minify,但其中没有000000文件夹。

W3 Total Cache Recommendations W3总缓存建议

Under the install tab for the plugin there is a note for people not using apache: 在插件的“安装”选项卡下,有一个针对未使用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. 在不使用Apache的情况下,位于WordPress安装目录根目录下的.htaccess文件wp-content / w3tc / pgcache / .htaccess和wp-content / w3tc / min / .htaccess包含必须手动配置的指令为您的Web服务器软件创建的。

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. 但是,不存在w3tc文件夹,只有一个w3tc-config文件夹,其中包含master.php和master-admin.php文件,没有.htaccess或子文件夹。 I checked a cache folder under wp-config and there is no .htaccess in any subfolder. 我检查了wp-config下的缓存文件夹,并且任何子文件夹中都没有.htaccess。 So I am not sure how to change the web.config or with what directives. 所以我不确定如何更改web.config或使用什么指令。

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: 我发现某个地方建议将这些重写规则添加到web.config中,我添加了它们,但它根本没有改变错误:

<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>

I ran into the same issue and here is the solution that worked for me: 我遇到了同样的问题,这是对我有用的解决方案:

W3 Total Cache: Version 0.9.4.1 W3总缓存:版本0.9.4.1

Wordpress: Version 4.5.2 WordPress:版本4.5.2

IIS: Version 7.5 IIS:7.5版

Server: Windows 2008 R2 伺服器:Windows 2008 R2

My web.config has these rules: 我的web.config具有以下规则:

<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. 当我将w3tc-minify-file规则放在我的wordpress规则下时,它不起作用,并且我在W3TC创建的所有缩小文件中都收到404错误。

I'm using manual mode minify and just combining my css and js files and it's working great. 我正在使用手动模式minify,并且仅将我的css和js文件组合在一起,效果很好。 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. 我有3个JS文件和2个CSS文件,我无法合并/缩小,因为它们破坏了我的网站。 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. 手动模式为您提供了最大的控制权,因此请花一些时间来添加每个文件,直到尽力而为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM