Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config not working with WordPress permalinks in sub folder

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?

like image 232
pee2pee Avatar asked Dec 23 '22 13:12

pee2pee


1 Answers

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.

like image 146
Berta Nicolau Avatar answered Mar 07 '23 08:03

Berta Nicolau