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>
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.
Related
I've just set up a IIS server, and made a simple website. I have a file called "image.aspx" and a directory called "image" and I have URL Rewrite 2.0 to not need the .aspx. When I see domain.com/image i get a no permission 403, but when I visit domain.com/image.aspx it shows. How can I make it that when you visit domain.com/image you go to domain.com/image.aspx but you are able to go to domain.com/image/file.aspx?
We just check if the file with the request URL name exists then make a redirection. Moreover, the specific file under that directory is accessible too.
<rules>
<rule name="MyRules" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{DOCUMENT_ROOT}{Request_URI}.aspx" matchType="IsFile" />
</conditions>
<action type="Redirect" url="Https://vabqia969vm:448{request_URI}.aspx" />
</rule>
</rules>
</rewrite>
Feel free to let me know if the problem still exists.
i am running my site from VS2013 IDE
i have include country code in url by http module like http://localhost:53741/gb/
but there is no folder called gb. so i suppose to get error. just to by pass that error i copy iis url rewrite rule in my web.config file. here it is
<rule name="Rewrite rule for Redirecting countries" stopProcessing="true">
<match url=".*" />
<conditions trackAllCaptures="true">
<add input="{REQUEST_URI}" pattern="[a-z]{2}/(.*)" />
</conditions>
<action type="Rewrite" url="/{tolower:{C:1}}" appendQueryString="false" logRewrittenUrl="true" />
</rule>
now the above url works but js and css file not downloaded. i checked with developer tool and js/css files path are ok.
my css is in content folder in root folder and js is in scripts folder. when i check the url of js and css then i found those was ok but files do not downloaded.....do not understand why?
here is developer tool screen shot
just see the file path from picture above. that is right.
i use this rule
<rule name="Some rule">
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v)$" negate="true" />
</conditions>
</rule>
but still no luck.what causing problem.anyone can help me to figure out this issue. thanks
I want to redirect "abc.aspx/" to "abc.aspx". How can this be done?
Page gets broken when requested page ends with '/'. How to handle such type of requests?
Is there any rewriting rule that can be added into web.config file?
In your web.config, under the system.webServer, add
<rewrite>
<rules>
<!--To always remove trailing slash from the URL-->
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
</rules>
</rewrite>
Some Gotchas
In your development environment, if you run your web site under Visual Studio Development Sever, you won't be able to see this feature working. You will need to configure your application to run under at least IIS Express.
When you deploy your web site and see that this feature is not working on your production server, it will be because you miss configured something. One of the common mistakes is having overrideModeDefault attribute set to Deny for rules under <sectionGroup name="rewrite"> inside your applicationHost.config file.
If you are on a shared hosting environment and you see that this feature is not working, ask your provider if they have given you the permission of configuring this part.
Source: http://www.tugberkugurlu.com/archive/remove-trailing-slash-from-the-urls-of-your-asp-net-web-site-with-iis-7-url-rewrite-module
I know this is an old post, but Mihai's answer can make your application vulnerable to open redirects attack (see this)
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
This redirect URL can be used for an external redirect, so make sure you have other validations in place before this rule is evaluated or change the redirect to make it internal instead. If you really want to remove the trailing slash and keep it internal, you can change it to:
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
Cheers
I am using WordPress on Windows 7 IIS to develop. I am uploading images in WordPress for a blog post. The image displays fine on the web site but as soon as I enable permalinks the images no longer work and any future images uploaded I get back an error:
HTTP Error 500.50 - URL Rewrite Module Error.
The page cannot be displayed because an internal server error has occurred.
I am not sure why this would be happening, here is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<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>
</system.webServer>
</configuration>
As soon as I turn off my permalinks and use the default it works, does anyone know why this could be?
The image issue was a permission issue, but simply setting it manually
on the original image file or parent folder is inadequate. The
behavior of WordPress is that it writes the original file using IUSR
to a temporary system directory that is defined in the PHP.ini file.
This temp folder does not have IIS_IUSRS permissions on it, so when
windows moves this file from the temp folder to the application's
upload folder, its final home, IIS_IUSRS only has read permissions, so
the permissions are not inherited from the file's parent folder.
To fix this, there are two solutions.
Change the permissions on the temp folder giving IIS_IUSRS write/modify.
Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.
Here is a good source detailing the problem:
http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/
I chose to move the temp folder in my PHP.ini to
C:\inetpub\temp\uploads and also give it permissions. After uploading
an image in wp-admin, I was able to access the image (original, not
resized) from a browser wihout the 500.50 error.
From source
There's a slightly different web.config at Using Permalinks « WordPress Codex as well as other options for Permalinks without mod rewrite on Windows.
To help other users this issue is due to permissions in IIS and a fix is also here:
http://forums.iis.net/t/1159252.aspx
use this below mention RULEs in your web.config file ..
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false"/>
<action type="None"/>
</rule>
<rule name="Redirect Image to HTTP" stopProcessing="true">
<match url=".*\.(gif|jpg|jpeg|png|css|js)$" ignoreCase="true"/>
<action type="Rewrite" url="{R:0}"/>
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="." ignoreCase="false"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="/index.php"/>
</rule>
I have just installed WordPress 3.0.1 running on MS IIS 6 Windows Server that I developed from my Mac OS X platform.
Note that my WordPress setup is under the following directory structure:
c:\inetpub\wwwroot\MYSITE
The problem here is though, with the site up and running, it can't seem to find any of my pages like "About Us" even though I have set them up correctly within the permalinks side of things.
I am getting:
HTTP Error 404 - File or directory not found. Internet Information Services (IIS)
Is it something to do with permalinks/.htaccess file not working on MS II6?
.htaccess files are for Apache HTTPD. They don't work with IIS. For IIS you need to create a "Web.config" file and add the following lines to it.
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<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>
DOESN'T WORK IN IIS6:
As Kev points out, this code doesn't work in IIS6. From a little googling I understand that URL rewriting is not at all possible with IIS6. If anyone knows another way, please update here.
POSSIBLE ALTERNATIVE FOR IIS6?
Is it possible to use ISAPI_Rewrite or UrlRewriter.NET in this situation? Can someone clarify on this?