Menu Close

Fix Permalinks for Child WordPress Sites

Permalinks are important for many reasons, specifically SEO purposes. In addition, many quality plugins require the use of permalinks in order to work properly. Sometimes however, I have issues getting permalinks to work for various reasons. One of the main issues I run into is using a child WordPress site nested within another WordPress site. The main site generally has its own rules for link redirects and sometimes it messes up the permalinks associated with the child site which throws 404 errors on certain pages. I had a hard time finding the code to fix this on a Windows hosting server since most of the documentation covers Linux. However, I found the solution and thought I would share it in case you are running into the same issue.

In order to fix it, you have to access to the Windows hosting server files, particularly the web.config file on the main directory of the child site.

Open up the web.config file in a text editor such as Notepad and copy the following code into that file (be sure not to replace any existing code to avoid breaking the site):

Web.config

<?xml version=”1.0″ encoding=:UTF-8″>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name=”MainSite”/>
<rule name=”WordPress: https://YOURSITE.com” 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>

Basically, this code is telling the browser to ignore the main WordPress site and match the URL to the child site. By taking the main site out of the equation, we are able to get permalinks to work flawlessly.

Any questions or other suggestions, please comment below!