Reputation: 3792
I have WP installed on an IIS server in the root folder. This works with pretty permalinks.
There is also another wordpress install at /development
which uses the following web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress1" 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>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
</staticContent>
</system.webServer>
</configuration>
However, pretty permalinks are not working on this site in the subfolder
The home page works however of this sub folder and when plain permalinks are selected
Any ideas why?
Upvotes: 5
Views: 3952
Reputation: 35843
As of WP 5.9 (but I am sure way back years and versions) there is no need to add web.config manually.
In case IIS rewrite module is installed (whichi is a prerequisite) when you modify Settings/Permalink, WP automatically emits web.config into the root of your site.
It even writes to the GUI a warning message, to revoke write access from web.config.
If IIS rewrite module is not installed, all of this above is not possible, neither manually, so WP will include the /index.php/
fragment in the path. If you overwrite this setting with a custom permalink setting, then the links will adopt (so will not contain the /index.php/
fragment, but because of lack of rewrite facility IIS will give 404
.
Upvotes: 0
Reputation: 128
The answer as pee2pee says, is to place that line in the code.
<remove name="YourRuleName"/>
To do this you must first look at the web.config file of the root and look for this line.
<rule name = "YourRuleName" patternSyntax = "Wildcard">
and then copy the line in the web.config file of your directory or subfolder, changing "YourRuleName" to the name you found in the web.config file of the root just above the first tag.
Then, your web.config file of the sub folder should look like
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="YourRuleName"/>
<rule name="YourSubFolderRuleName" 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>
I hope it is helpful, for me it has been.
Upvotes: 7
Reputation: 3792
Ensure the root folder (serving the primary site) and the subfolder (where the secondary or /shop resides) each have a unique web.config file.
In your subfolder’s web.config file you need to remove the rule that was set in the root folder. In our case, the WordPress rewrite rule set in the root folder was called “PrimarySite”, so in the subfolder’s web.config we have:
<remove name="PrimarySite"/>
And that’s all it took to get things working. Simple, eh?
Upvotes: 3