I am here sharing my experience of having a twist with multiple wordpress sites (PHP) on IIS.
I feel it is important for sharing this info as it may be of prudent importance for developers or managers who has to deploy multiple websites on wordpress.
During one of my assignments recently, I had to deploy multiple websites on IIS host.
To host multiple sites you will have to create folders for each site inside main site.
Now, each folder represents a different site and its domain.
In IIS there is no .htaccess file where you can setup the rules.
For this you will need to add your rules for different domains in web.config
All these rules needs to be there in web.config which is inside the root folder.
There will be set of rules for each site.
the very first rule is to redirect the domain
<rule name="www.yourdomain.com" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
<add input="{PATH_INFO}" pattern="^/yourdomain/ " negate="true" />
</conditions>
<action type="Rewrite" url="\yourdomain\index.php\{R:0}" />
</rule>
In the above rule, the "yourdomain.com" will be matched with the url pattern.
When pattern is matched the path is redirect to the yourdomain folder.
and will replace the index.php to make the url SEO friendly.
To make this work you will need to remove "index.php" from permalink settings from
the WP-Admin section.
The above link resolves the redirection issue.
But when you try this alone you will not get the CSS/Images or other assets and media objects
necessary for the site to load perfectly.
All the CSS/Images/Javascript necessary is inside the wp-content/wp-includes and wp-admin
considering this I created the rule that will set the correct path to download all
the requisite files needed.
<rule name="WordPress yourdomain" stopProcessing="true">
<match url="(^(www.)?yourdomain.com+/)?(wp-(content|admin|includes).*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
</conditions>
<action type="Rewrite" url="yourdomain/{R:3}" />
</rule>
So the above rule resolved the CSS and other issues related to the look and feel.
Each site is having a sitemap file which is necessary for the google analytics to work and also
for SEO indexing.
So we will need to allow download of sitemap.xml file
For this the following rule may apply.
<rule name="WordPress yourdomainSettings" stopProcessing="true">
<match url="(^(www.)?yourdomain.com+/)?((sitemap.xml))" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
</conditions>
<action type="Rewrite" url="yourdomain/{R:0}" />
</rule>
One thing to note is this that the rule name should not be repeated in the web.config. Each rule must have a unique name.
Happy coding..
I feel it is important for sharing this info as it may be of prudent importance for developers or managers who has to deploy multiple websites on wordpress.
During one of my assignments recently, I had to deploy multiple websites on IIS host.
To host multiple sites you will have to create folders for each site inside main site.
Now, each folder represents a different site and its domain.
In IIS there is no .htaccess file where you can setup the rules.
For this you will need to add your rules for different domains in web.config
All these rules needs to be there in web.config which is inside the root folder.
There will be set of rules for each site.
the very first rule is to redirect the domain
<rule name="www.yourdomain.com" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
<add input="{PATH_INFO}" pattern="^/yourdomain/ " negate="true" />
</conditions>
<action type="Rewrite" url="\yourdomain\index.php\{R:0}" />
</rule>
In the above rule, the "yourdomain.com" will be matched with the url pattern.
When pattern is matched the path is redirect to the yourdomain folder.
and will replace the index.php to make the url SEO friendly.
To make this work you will need to remove "index.php" from permalink settings from
the WP-Admin section.
The above link resolves the redirection issue.
But when you try this alone you will not get the CSS/Images or other assets and media objects
necessary for the site to load perfectly.
All the CSS/Images/Javascript necessary is inside the wp-content/wp-includes and wp-admin
considering this I created the rule that will set the correct path to download all
the requisite files needed.
<rule name="WordPress yourdomain" stopProcessing="true">
<match url="(^(www.)?yourdomain.com+/)?(wp-(content|admin|includes).*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
</conditions>
<action type="Rewrite" url="yourdomain/{R:3}" />
</rule>
So the above rule resolved the CSS and other issues related to the look and feel.
Each site is having a sitemap file which is necessary for the google analytics to work and also
for SEO indexing.
So we will need to allow download of sitemap.xml file
For this the following rule may apply.
<rule name="WordPress yourdomainSettings" stopProcessing="true">
<match url="(^(www.)?yourdomain.com+/)?((sitemap.xml))" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?yourdomain.com?" />
</conditions>
<action type="Rewrite" url="yourdomain/{R:0}" />
</rule>
One thing to note is this that the rule name should not be repeated in the web.config. Each rule must have a unique name.
Happy coding..