WordPress.org

Forums

[resolved] WordPress installation on Root Folder & Sub Folder on IIS Server, url conflict (5 posts)

  1. Samrat Saha
    Member
    Posted 1 year ago #

    Hello,

    I had a IIS Server hosting, where my personal site is on the root folder, and now i need to place another wordpress installation on the sub-folder, after doing so everything is working fine except when the 'Permalink Settings' is set to /%postname%/ in both the wp installation i.e., on the root and sub-folder then except index page of sub-folder every page is showing 404 error.

    Please Help.

  2. 2ninerniner2
    Member
    Posted 1 year ago #

    This may help, especially the section on Permalinks in a sub directory installation:

    http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/install-wordpress-on-iis

  3. Samrat Saha
    Member
    Posted 1 year ago #

    WordPress in both root and subfolder (Windows Server IIS) with pretty permalink (/%postname%/) in both[Solved !!!]

    Web.config in Main Root Folder as you want.
    //Code-----

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
    	  		<clear />
    			<rule name="MainWordpressFolder" 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>

    //Important point to follow in above code
    #Add <clear /> after <rules> started...
    #<rule name="MainWordpressFolder" will be unique in all web.config(s) of your hosting.

    Web.config in Sub Folder as you want.

    //Code-----

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
    	  		<clear />
    			<rule name="SubWordpressFolder" stopProcessing="true">
    				<match url=".*" />
    					<conditions>
    						<add input="{HTTP_HOST}" pattern="^(www.)?youranotherdomain.com" />
    						<add input="{PATH_INFO}" pattern="^/" negate="true" />
    					</conditions>
    				<action type="Rewrite" url="\your\sub\domain\directory\path\{R:0}" />
    			</rule>
    
    			<rule name="SubWordpressFolder-wp" 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>

    //Important point to follow in above code
    #Add <clear /> after <rules> started...
    #First <rule> needed to be defined carefully as described above.
    #Second <rule> will be generated from wordpress admin (on permalink change from settings) after generation of above rule, rename the rule name to any-unique-name-of-your-choice

    Enjoy :)

  4. galpeaceman
    Member
    Posted 1 year ago #

    Thanks for the advise! I was truly lost with this crazy IIS stuff.
    But..... it did not work until I changed <match url="*"/> to <match url=".*"/> in both wp rules

  5. leventkaya
    Member
    Posted 8 months ago #

    @Samrat Saha
    Thank you so much, your solution works on my situation.

Topic Closed

This topic has been closed to new replies.

About this Topic