adding www to URL with Wordpress, IIS and Mobile enabled sites (m.)

Posted on 2011-10-01
Last Modified: 2012-05-12
Hi Experts,

I have an issue with URL rewrite Module.
I am getting infinite loop issues.

When I type in "" I am getting infinite loop when I want it to 301 redirect to ""
Also when I type in "" I get the same error, it should redirect to ""

Wordpress v3.2.1

WordPress address (URL):
Site address (URL):

Plugins Installed:

Current IIS web.config rewrite rule
				<rule name="Redirect /(.*) to /strange-tours-melbourne/(.*) " enabled="true" stopProcessing="true">                 
					<match url="(.*)" />                    
					 <conditions logicalGrouping="MatchAny">   
						<add input="{REQUEST_URI}" pattern="^/strange-tours-melbourne/(.*)$" negate="true" />                      
					<action type="Redirect" url="http://{HTTP_HOST}/strange-tours-melbourne/{R:1}" appendQueryString="false" redirectType="Permanent" />                

Open in new window

Resources I have read and tried out

Your thoughts are appreciated.
Question by:Craig Lambie
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    i'm guessing that you got it fixed as it seems to work fine from here.. except gives an error
    XML Parsing Error: mismatched tag. Expected: </div>.
    Line Number 102, Column 5:  </body>

    LVL 1

    Author Comment

    by:Craig Lambie
    It does appear to be working :)
    As in actually redirecting to the /strange-tours-melbourne/ virtual folder on IIS, however if I look at the server headers for with and without the www. I am getting a 200 on both now.
    Ideally I want a 301 on the without, so that their is no duplicate content going on, which will require some sort of rule change?

    I am not getting that error in the XML parsing on the home page... but I found one :) on another page.
    I am using safari and Chrome to check the Mobile sites, and android and iphone browsers.

    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    the </div> in question starts on line 75 <body class="base"> <div id="wrap"> and is not closed before the </body>

    well it is redirecting as it should in the url rewrite. without the rewrite you would get the 301 redirect
    LVL 1

    Author Comment

    by:Craig Lambie
    Not sure what browser you are using, but I get a matching <div> to that in Chrome and Safari when I run the page?

    When I check the server headers on this page
    I get
    Response code
    *200 for
    200 for
    301 for
    301 for

    What I want is 301 for * as I only want Google etc for SEO to see the one content page :)
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    run your site through the w3c validator and firefox gave me the error
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    check your dns settings for the and the
    LVL 1

    Author Comment

    by:Craig Lambie
    dns settings?
    What about them sorry.
    They both A records point at the IP address, should one point at the domain or something?
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    so you have and both pointing to your web servers ip address ergo they will give a 200 reply as there is no redirection

    there are a few 404's here
    8224086 ==
    8224088 ==
    8224089 ==

    [02:34:00.786] GET [HTTP/1.1 200 OK 1872ms]
    [02:34:02.629] GET [HTTP/1.1 200 OK 821ms]
    [02:34:02.689] GET [HTTP/1.1 304 Not Modified 889ms]
    [02:34:02.700] GET [HTTP/1.1 304 Not Modified 917ms]
    [02:34:02.727] GET [HTTP/1.1 304 Not Modified 918ms]
    [02:34:02.737] GET [HTTP/1.1 304 Not Modified 1571ms]
    [02:34:02.758] GET [HTTP/1.1 304 Not Modified 1574ms]
    [02:34:02.771] GET [HTTP/1.1 304 Not Modified 1627ms]
    [02:34:02.836] GET [HTTP/1.1 200 OK 1494ms]
    [02:34:04.472] GET [HTTP/1.1 302 Found 1342ms]
    [02:34:04.517] GET [HTTP/1.1 200 OK 1085ms]
    [02:34:04.542] GET [HTTP/1.1 404 Not Found 1704ms]
    [02:34:05.980] GET [HTTP/1.1 302 Found 613ms]
    [02:34:06.250] GET [HTTP/1.1 200 OK 1294ms]
    [02:34:06.272] GET [HTTP/1.1 200 OK 1406ms]
    [02:34:06.318] GET [HTTP/1.1 200 OK 2286ms]
    [02:34:06.661] GET [HTTP/1.1 200 OK 2449ms]
    [02:34:06.720] GET [HTTP/1.1 200 OK 2729ms]

    Open in new window

    [02:36:35.458] GET [HTTP/1.1 200 OK 1742ms]
    [02:36:37.233] GET [HTTP/1.1 200 OK 928ms]
    [02:36:37.268] GET [HTTP/1.1 304 Not Modified 507ms]
    [02:36:37.278] GET [HTTP/1.1 304 Not Modified 525ms]
    [02:36:37.291] GET [HTTP/1.1 304 Not Modified 1020ms]
    [02:36:37.302] GET [HTTP/1.1 304 Not Modified 1102ms]
    [02:36:37.321] GET [HTTP/1.1 304 Not Modified 1115ms]
    [02:36:37.332] GET [HTTP/1.1 304 Not Modified 1141ms]
    [02:36:37.381] GET [HTTP/1.1 200 OK 899ms]
    [02:36:38.586] GET [HTTP/1.1 302 Found 951ms]
    [02:36:38.621] GET [HTTP/1.1 200 OK 785ms]
    [02:36:38.642] GET [HTTP/1.1 404 Not Found 1534ms]
    [02:36:39.745] GET [HTTP/1.1 302 Found 569ms]
    [02:36:40.008] GET [HTTP/1.1 200 OK 712ms]
    [02:36:40.032] GET [HTTP/1.1 200 OK 765ms]
    [02:36:40.080] GET [HTTP/1.1 200 OK 1008ms]
    [02:36:40.150] GET [HTTP/1.1 200 OK 1526ms]
    [02:36:40.237] GET [HTTP/1.1 200 OK 1748ms]

    Open in new window

    [02:38:00.917] GET [HTTP/1.1 200 OK 2966ms]
    [02:38:03.646] GET [HTTP/1.1 404 Not Found 1972ms]
    [02:38:03.655] GET [HTTP/1.1 404 Not Found 2697ms]
    [02:38:03.666] GET [HTTP/1.1 404 Not Found 2818ms]
    [02:38:06.530] GET [HTTP/1.1 304 Not Modified 753ms]
    [02:38:06.541] GET [HTTP/1.1 304 Not Modified 784ms]
    [02:38:06.555] GET [HTTP/1.1 304 Not Modified 803ms]
    [02:38:06.708] GET [HTTP/1.1 200 OK 772ms]
    [02:38:07.308] GET [HTTP/1.1 304 Not Modified 635ms]
    [02:38:08.031] GET [HTTP/1.1 304 Not Modified 512ms]
    [02:38:08.584] GET [HTTP/1.1 304 Not Modified 363ms]

    Open in new window

    LVL 1

    Author Comment

    by:Craig Lambie
    right, so that is my original question comes from, I want it to 301 redirect (it wasn't coming up at all before, but now it appears to be at least coming up)

    How did you get that output? Seems like a good way to test themes etc for broken links (as you have shown :) - thanks
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    firefox 7 just about the same is available with ie9 (hit f12)
    LVL 1

    Author Comment

    by:Craig Lambie
    Ok, but still no answer to my original question - URLRewrite rule that will work to add the www. when there isn't one as a 301??
    LVL 77

    Accepted Solution

    in the www.* site create a binding
    then create a blank website binding
    go into the configuration editor under system.web.server/httpredirect
    put the destination as the
    now you should get the 301 redirects

    url rewrite should always give a 200 ok response

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following:…
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now