URL rewriting with Word Press and non WP-folders in same directory

Discussion in 'Site Programming, Development and Design' started by Scott Stoecker, Apr 17, 2014.

  1. I have a basic URL rewrite rule that redirects a domain hosted by another site to a subdirectory on Winhost. This is working for the home page of my blog, a Word Press site, which is appearing as expected:

    <rule name="MySite" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" matchType="Pattern" pattern="^(www.)?MySite.com" ignoreCase="true" negate="false" />
    <add input="{PATH_INFO}" pattern="^/MySite/" negate="true" />
    <add input="{URL}" negate="true" pattern="\.axd$" />
    </conditions>
    <action type="Rewrite" url="\MySite\{R:0}" />
    </rule>

    But, if I click on any of the links in Word Press, such as a post name, or a category name, the redirect script tries to pass the request onto an actual file, and it fails, because there is no file, it's in the MySQL database.

    Another complication is that there ARE actually directories mixed in with the Word Press stuff, so my directory looks like this, with MySite being the blog site that contains other directories as well:

    Root
    - MySite
    - Folder1
    - Folder2
    - wp-admin
    index.php
    wp-login.php
    ...

    Is there a script I can write to somehow know that a request is for a Word Press site, or am I going to have to either write specific redirects for each folder (so a rule to direct requests to MySite\Folder1), or redesign the way my folders are laid out?

    Thanks,
    Scott
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    I'm a little confused. What do you mean by: - redirects a domain hosted by another site to a subdirectory on Winhost- ?
    What is this other site? Why not just associate and attach/bind the domain name to that Winhost account?
     
    Last edited by a moderator: Oct 14, 2015
  3. My explanation was poor. I meant that my domain name is hosted on Register.com, and that the DNS entries point to Winhost, where I have a single hosting plan that holds multiple domain names.

    I made some progress on my issue. I have a folder, Stories, that, using the following rule, successfully handles requests to the Stories directory:

    <rule name="Stories" stopProcessing="true">
    <match url="^Stories$" />
    <action type="Rewrite" url="\Wunderhund\Stories" />
    </rule>

    My main site directory, which hosts a Word Press blog, is almost working. My rule looks like this:

    <rule name="Wunderhund" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" matchType="Pattern" pattern="^(www.)?wunderhund.com" ignoreCase="true" negate="false" />
    </conditions>
    <action type="Rewrite" url="\Wunderhund\{R:0}" />
    </rule>

    If I view the main blog site, it shows up. If I try to log into edit a post using the wp-login link, that also works since there is an actual wp-login.php file.

    The problem occurs if I try to view an individual post, or click on a link to one of the categories (which has a URL of http://wunderhund.com/category/technology/). Since there is no corresponding file, I get a 404. Is there a method to get those non-pages working?

    Thanks,
    Scott
     
    Last edited by a moderator: Oct 14, 2015

Share This Page