How to redirect website without affecting blog?

I’m running an Asp.Net (4.0) website. There also a WordPress blog on the same machine.

The blog is a folder under the main domain: www.mydomain/blog/

Read More

Here is the problem.

I’ve just been doing some page analysis and discovered that link juice is being split between pages with a trailing slash and pages without a trailing slash.

I found the code to remove the trailing slash (my preferred option) and added it to my web config – it which works on the main site but causes problems with WordPress.

    <rule name="Remove trailing slash">
      <match url="(.*)/$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{R:1}" />
    </rule>

The code isn’t the problem. Asp.Net routing in (4.0) creates routes without a trailing slash – WordPress on the other hand, creates routes with a trailing slash – therefore implementing the code in my main web.config causes a loop problem. I’m also worried about the SEO affects.

Is there a way I can modify the above code so that it kicks in for the main site and not for the blog?

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. Try adding this line of xml into the conditions:

    <add input="{REQUEST_FILENAME}" 
         matchType="Pattern" 
         pattern="/blog/$" 
         negate="true" />
    

    It should tell the redirect to not fire if it ends in /blog/