Pretty Permalinks for Multiple Wordpress blogs in sub folders on Windows Hosting with IIS
https://www.zyxware.com/sites/default/files/styles/user_image/public/pictures/zyxlogo.png?itok=J9t-ZEoU
BY webmaster
12 years ago
Web-Development
8 comments comment
We recently had a customer who had Windows Hosting with IIS and she had two WordPress blogs hosted on two subdirectories on the same hosting space. Windows hosting should be the last thing that should come to your mind when you want to do WordPress hosting as it will never come close to LAMP (Linux, Apache, MySQL, PHP) functionalities. Now the problem was that she could not set up Permalinks on both blogs. There was an already published solution on how to setup Permalinks in Wordpress on IIS but we had to tweak that a little to get it working in this scenario. The original solution involved the use ofcustom 404 files to handle Permalinks. Since permalinks are not actual pages they will always trigger a 404 error on an IIS server. Now by assigning our own php file to handle this error we can easily parse the URL requested and pass it on to index.php to simulate url-rewrites.

The solution presented in the above site allowed for a single wordpress installation. Here we had two wordpress installations in two sub directories. The solution was to process the request and identify the installation corresponding to which the request was made based on the sub-folder name. Once this was done all we had to do was change directories (for the case where it was needed) and then include the corresponding index.php. We had to chdir because otherwise the working directory would have been the directory where the 404 handler file is located and this could only work for a single installation.

The code used is given below. Copy this and modify for your needs when you have multiple wordpress installations under a domain in IIS and you want Pretty Permalinks for all of them
<?php
$_SERVER['REQUEST_URI'] = substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], ':80')+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
if(stristr($_SERVER['QUERY_STRING'], '/blog/'))
  include('index.php');
elseif (stristr($_SERVER['QUERY_STRING'], '/books/'))
{
  chdir('../books/');
  include('../books/index.php');
}
else
  header("location:http://4sometime.com/blog");
If you have questions or problems, use the form given below and we can try to help you. Ideally you should be looking for Linux Hosting Plans when you are looking at Wordpress as your blogging engine. You can also take a look at our competitively priced Linux Hosting Plans

RELATED ARTICLE

/themes/custom/zyxpro_light/images/placeholder.png
close

on 09th June 2008 / by webmaster
We recently had a customer who had Windows Hosting with IIS and she had two WordPress blogs hosted on two subdirectories on the same hosting space. Windows hosting should be the last thing that should come to your mind when you want to do WordPress hosting as it will never come close to LAMP (Linux, Apache, MySQL, PHP) functionalities. Now the problem was that she could not set up Permalinks on both blogs. There was an already published solution on how to setup Permalinks in Wordpress on IIS but we had to tweak that a little to get it working in this scenario. Web Development Wordpress Blogging Leave a reply Your email address will not be published. Required fields are marked * thinkdj (not verified) access_time 21 Oct 2020 - 14:40 I came here via google.. Im so happy to see Zyxware publishing articles :) I have a wp installation in the root and just installed another one in a subdir. So, both these pages exist : My problem is that when http://example.com/new-wp-install/about is requested, it's being redirected to http://example.com/about as the default mod_rewrite rules check only the last part "about" and redirect to the main install. Anoop chetta, do you know the regex for fixing this in htaccess ? I tried a lot of patterns . . no avail Also, it may work if we set to parse .htaccess from each subdirectory where it exists and not just from the root ? Is that possible ? webmaster access_time 21 Oct 2020 - 14:40 In reply to I came here via google.. Im by thinkdj (not verified) Can you please post the rewrite rule and a simple regex match on new-wp-install\/about should do the trick. Anoop John yuda (not verified) access_time 21 Oct 2020 - 14:40 Hi guys Yesterday I had to install a second WP installation on the same IIS shared hosting account. But that's not all... It was a double WP install, on the same hosting account, using 2 different domains, on one of them the blog is not even served from the "real" hosting path, and where both supposed to use pretty permalinks. If this is not already a WP-routing nightmare, it was all had to be done under a Windows hosting environment - and this actually posed the biggest hurdle! Installing Apache-like mod_rewrite ISAPI's is out of the question on a shared host, so I was left with the dreaded single error page for the entire account. And I'm sure no PHP wiz... And here is where your script helped me, in guiding me in the right path. After a some tinkering with your code, the host's domain-pointing and URL redirection, and WP own redirect, it all now plays nicely, thank god... and you! So all the best and keep posting your coding tips - you may never know when it will save someone from the other side of the world. Yuda webmaster access_time 21 Oct 2020 - 14:40 In reply to You have no idea how much this has helped me! by yuda (not verified) Thanks for the good words. If this article really helped you, do blog about it and link to this page to spread the word. Cheers Anoop John Zyxware ??????????? ?????? (not verified) access_time 21 Oct 2020 - 14:40 Cool! I think It;s a good way to know how the tools can work. Useful information. Thanks for sharng. Good Luck. we have put a link to it on our page :-) Pagination Current page 1 Page 2 Next page Next › Last page Last » Add new comment
Leave a reply
Your email address will not be published. Required fields are marked *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

author-image
thinkdj (not verified)
access_time 21 Oct 2020 - 22:29

I came here via google.. Im so happy to see Zyxware publishing articles :)

I have a wp installation in the root and just installed another one in a subdir.
So, both these pages exist :

My problem is that when http://example.com/new-wp-install/about is requested, it's being redirected to http://example.com/about as the default mod_rewrite rules check only the last part "about" and redirect to the main install.

Anoop chetta, do you know the regex for fixing this in htaccess ? I tried a lot of patterns . . no avail

Also, it may work if we set to parse .htaccess from each subdirectory where it exists and not just from the root ? Is that possible ?


author-image
Can you please post the rewrite rule and a simple regex match on new-wp-install\/about should do the trick. Anoop John

author-image
yuda (not verified)
access_time 21 Oct 2020 - 22:29

Hi guys

Yesterday I had to install a second WP installation on the same IIS shared hosting account. But that's not all...

It was a double WP install, on the same hosting account, using 2 different domains, on one of them the blog is not even served from the "real" hosting path, and where both supposed to use pretty permalinks.

If this is not already a WP-routing nightmare, it was all had to be done under a Windows hosting environment - and this actually posed the biggest hurdle!

Installing Apache-like mod_rewrite ISAPI's is out of the question on a shared host, so I was left with the dreaded single error page for the entire account. And I'm sure no PHP wiz...

And here is where your script helped me, in guiding me in the right path. After a some tinkering with your code, the host's domain-pointing and URL redirection, and WP own redirect, it all now plays nicely, thank god... and you!

So all the best and keep posting your coding tips - you may never know when it will save someone from the other side of the world.

Yuda



author-image
??????????? ?????? (not verified)
access_time 21 Oct 2020 - 22:29

Cool! I think It;s a good way to know how the tools can work.
Useful information. Thanks for sharng. Good Luck.

we have put a link to it on our page :-)