404 error Wordpress trying to remove index.php

Discussion in 'General troubleshooting' started by mrsandip, Nov 5, 2019.

  1. Trying to have pretty Permalinks on wordpress sites without the pesky index.php show up on URL and mess with SEO. In wordpress, if I put structure as https://site1.com/post-name/ I get 404 errors for all pages in the menu with following info:
    Requested URL: https://site1.com:443/site1folder/page-name/
    Physical path: e:\web\root\site1folder\page-name\

    If I put structure as https://site1.com/index,php/post-name/ they work fine but then index.php shows up on browser URL and is not good for SEO.

    Below is what's in web.config in root:
    <rule name="https://site1.com" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="^www\.site1\.com$" />
    </conditions>
    <action type="Redirect" url="https://site1.com/{R:1}" />
    </rule>
    <rule name="http://site2.com" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="^www\.site2\.com$" />
    </conditions>
    <action type="Redirect" url="http://site2.com/{R:1}" />
    </rule>
    <rule name="site1.com" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="^(www\.)?site1\.com$" />
    <add input="{PATH_INFO}" pattern="^/site1folder($|/)" negate="true" />
    </conditions>
    <action type="Rewrite" url="\site1folder\{R:0}" />
    </rule>
    <rule name="site2.com" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="^(www\.)?site2\.com$" />
    <add input="{PATH_INFO}" pattern="^/site2folder($|/)" negate="true" />
    </conditions>
    <action type="Rewrite" url="\site2folder\{R:0}" />
    </rule>
    The sites are responding to their URLs so I assume the web.config in root is working fine.

    In the site1folder, I have web.config with following code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <defaultDocument>
    <!-- Set the default document -->
    <files>
    <remove value="index.php" />
    <add value="index.php" />
    </files>
    </defaultDocument>
    <httpErrors errorMode="Detailed"/>
    <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>

    What am I missing or need to do so index.php doesn't show up on browser URL?
     
  2. Fix for Local Servers
    Often designers and developers install WordPress on their computers using a local server for testing purposes. If you want to use pretty permalinks, then you need to enable the rewrite_module in the Apache configuration of your MAMP, WAMP, or XXAMP.

    Regards,
    Bruce
     

Share This Page