[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

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

Hi Experts,

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

Problem:
When I type in "truesecrets.com.au" I am getting infinite loop when I want it to 301 redirect to "http://www.truesecrets.com.au/strange-tours-melbourne/"
Also when I type in "m.truesecrets.com.au" I get the same error, it should redirect to "http://m.truesecrets.com.au/strange-tours-melbourne/"

Setup
IIS 7
Wordpress v3.2.1

WordPress address (URL): http://www.truesecrets.com.au/strange-tours-melbourne/
Site address (URL): http://www.truesecrets.com.au/strange-tours-melbourne/

Plugins Installed:
PrettyLink

Current IIS web.config rewrite rule
<rewrite>
			<rules>
				<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" />                      
					 </conditions>  
					<action type="Redirect" url="http://{HTTP_HOST}/strange-tours-melbourne/{R:1}" appendQueryString="false" redirectType="Permanent" />                
				</rule> 
			</rules>
		</rewrite>

Open in new window


Resources I have read and tried out
http://brad.kingsleyblog.com/post/URL-Rewrite-Sample-to-Add-www-to-the-URL.aspx
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/
http://www.jtpratt.com/making-wordpress-permalinks-work-on-windows-iis-godaddy-without-mod_rewrite/

Your thoughts are appreciated.
0
Craig Lambie
Asked:
Craig Lambie
  • 7
  • 5
1 Solution
 
David Johnson, CD, MVPOwnerCommented:
i'm guessing that you got it fixed as it seems to work fine from here.. except m.trusecrets.com.au/strange-tours-melbourne gives an error
XML Parsing Error: mismatched tag. Expected: </div>.
Location: http://m.truesecrets.com.au/strange-tours-melbourne/
Line Number 102, Column 5:  </body>
----^

0
 
Craig LambieAuthor Commented:
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?
Thoughts?

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.

0
 
David Johnson, CD, MVPOwnerCommented:
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
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
Craig LambieAuthor Commented:
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 http://truesecrets.com.au/strange-tours-melbourne/
200 for http://www.truesecrets.com.au/strange-tours-melbourne/
301 for http://truesecrets.com.au/
301 for http://www.truesecrets.com.au/

What I want is 301 for * as I only want Google etc for SEO to see the one content page :)
Thoughts?
0
 
David Johnson, CD, MVPOwnerCommented:
run your site through the w3c validator and firefox gave me the error
0
 
David Johnson, CD, MVPOwnerCommented:
check your dns settings for the truesecrets.com and the www.truesecrets.com
0
 
Craig LambieAuthor Commented:
dns settings?
What about them sorry.
They both A records point at the IP address, should one point at the domain or something?
0
 
David Johnson, CD, MVPOwnerCommented:
so you have www.truesecrets.com.au and truesecrets.com.au 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 == truesecrets.com.au
8224088 == www.truesecrets.com.au
8224089 == m.truesecrets.com.au



[02:34:00.786] GET http://truesecrets.com.au/strange-tours-melbourne/ [HTTP/1.1 200 OK 1872ms]
[02:34:02.629] GET http://www.google-analytics.com/__utm.gif?utmwv=5.1.7&utms=6&utmn=880311687&utmhn=truesecrets.com.au&utmcs=UTF-8&utmsr=1920x1080&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=11.0%20d1&utmdt=Strange%20things%20to%20do%20in%20Melbourne&utmhid=780910190&utmr=-&utmp=%2Fstrange-tours-melbourne%2F&utmac=UA-25243711-1&utmcc=__utma%3D261155528.1557877217.1317611938.1317611938.1317623233.2%3B%2B__utmz%3D261155528.1317623233.2.2.utmcsr%3Dexperts-exchange.com%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FSoftware%2FServer_Software%2FWeb_Servers%2FMicrosoft_IIS%2FQ_27375877.html%3B&utmu=q~ [HTTP/1.1 200 OK 821ms]
[02:34:02.689] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/formidable/css/frm_display.css?ver=1.05.05 [HTTP/1.1 304 Not Modified 889ms]
[02:34:02.700] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelementplayer.css?ver=3.2.1 [HTTP/1.1 304 Not Modified 917ms]
[02:34:02.727] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/l10n.js?ver=20101110 [HTTP/1.1 304 Not Modified 918ms]
[02:34:02.737] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/jquery/jquery.js?ver=1.6.1 [HTTP/1.1 304 Not Modified 1571ms]
[02:34:02.758] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelement-and-player.min.js?ver=3.2.1 [HTTP/1.1 304 Not Modified 1574ms]
[02:34:02.771] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-admin/js/password-strength-meter.js?ver=20101027 [HTTP/1.1 304 Not Modified 1627ms]
[02:34:02.836] GET http://www.jscache.com/wejs?wtype=linkingWidget&uniq=744&locationId=2306432&lang=en_AU [HTTP/1.1 200 OK 1494ms]
[02:34:04.472] GET http://www.facebook.com/plugins/likebox.php?href=https://www.facebook.com/pages/True-Secrets-Melbourne/173988669303957&width=180&colorscheme=light&show_faces=false&connections=1&stream=false&header=false&height=130 [HTTP/1.1 302 Found 1342ms]
[02:34:04.517] GET http://www.tripadvisor.com.au/WidgetEmbed-linkingWidget?uniq=744&locationId=2306432&lang=en_AU [HTTP/1.1 200 OK 1085ms]
[02:34:04.542] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/themes/one-more-night-10/images/sidebar-h2-bg.gif [HTTP/1.1 404 Not Found 1704ms]
[02:34:05.980] GET http://www.facebook.com/plugins/like.php?action=recommend&channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df1c4f3d55fe0cd2%26origin%3Dhttp%253A%252F%252Ftruesecrets.com.au%252Ff287bc473a6709c%26relation%3Dparent.parent%26transport%3Dpostmessage&extended_social_context=false&href=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&layout=button_count&locale=en_US&node_type=link&sdk=joey&send=false&show_faces=false&width=450 [HTTP/1.1 302 Found 613ms]
[02:34:06.250] GET http://platform.twitter.com/widgets/images/t.gif?_=1317623645572&count=horizontal&id=twitter_tweet_button_0&lang=en&original_referer=http%3A%2F%2Ftruesecrets.com.au%2Fstrange-tours-melbourne%2F&text=%40TrueSecretsMelb%20is%20an%20awesome%20experience%20in%20%23Melbourne%20Australia%20%23ThingsToDo&url=m.truesecrets.com.au&twttr_referrer=http%3A%2F%2Ftruesecrets.com.au%2Fstrange-tours-melbourne%2F&twttr_li=1&twttr_widget=1&twttr_guest_id=v1%3A131734641621996305 [HTTP/1.1 200 OK 1294ms]
[02:34:06.272] GET http://cdn.api.twitter.com/1/urls/count.json?url=m.truesecrets.com.au&callback=twttr.receiveCount [HTTP/1.1 200 OK 1406ms]
[02:34:06.318] GET https://plusone.google.com/u/0/_/+1/fastbutton?url=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&size=medium&count=true&annotation=&hl=en-GB&jsh=r%3Bgc%2F23980661-3686120e#id=I1_1317623646033&parent=http%3A%2F%2Ftruesecrets.com.au&rpctoken=318954867&_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe [HTTP/1.1 200 OK 2286ms]
[02:34:06.661] GET https://www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FTrue-Secrets-Melbourne%2F173988669303957&width=180&colorscheme=light&show_faces=false&connections=1&stream=false&header=false&height=130 [HTTP/1.1 200 OK 2449ms]
[02:34:06.720] GET https://www.facebook.com/plugins/like.php?action=recommend&channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df1c4f3d55fe0cd2%26origin%3Dhttp%253A%252F%252Ftruesecrets.com.au%252Ff287bc473a6709c%26relation%3Dparent.parent%26transport%3Dpostmessage&extended_social_context=false&href=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&layout=button_count&locale=en_US&node_type=link&sdk=joey&send=false&show_faces=false&width=450 [HTTP/1.1 200 OK 2729ms]

Open in new window

[02:36:35.458] GET http://www.truesecrets.com.au/strange-tours-melbourne/ [HTTP/1.1 200 OK 1742ms]
[02:36:37.233] GET http://www.google-analytics.com/__utm.gif?utmwv=5.1.7&utms=7&utmn=1800839556&utmhn=www.truesecrets.com.au&utmcs=UTF-8&utmsr=1920x1080&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=11.0%20d1&utmdt=Strange%20things%20to%20do%20in%20Melbourne&utmhid=379540467&utmr=-&utmp=%2Fstrange-tours-melbourne%2F&utmac=UA-25243711-1&utmcc=__utma%3D261155528.1557877217.1317611938.1317611938.1317623233.2%3B%2B__utmz%3D261155528.1317623233.2.2.utmcsr%3Dexperts-exchange.com%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FSoftware%2FServer_Software%2FWeb_Servers%2FMicrosoft_IIS%2FQ_27375877.html%3B&utmu=q~ [HTTP/1.1 200 OK 928ms]
[02:36:37.268] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/formidable/css/frm_display.css?ver=1.05.05 [HTTP/1.1 304 Not Modified 507ms]
[02:36:37.278] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelementplayer.css?ver=3.2.1 [HTTP/1.1 304 Not Modified 525ms]
[02:36:37.291] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/l10n.js?ver=20101110 [HTTP/1.1 304 Not Modified 1020ms]
[02:36:37.302] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/jquery/jquery.js?ver=1.6.1 [HTTP/1.1 304 Not Modified 1102ms]
[02:36:37.321] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelement-and-player.min.js?ver=3.2.1 [HTTP/1.1 304 Not Modified 1115ms]
[02:36:37.332] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-admin/js/password-strength-meter.js?ver=20101027 [HTTP/1.1 304 Not Modified 1141ms]
[02:36:37.381] GET http://www.jscache.com/wejs?wtype=linkingWidget&uniq=744&locationId=2306432&lang=en_AU [HTTP/1.1 200 OK 899ms]
[02:36:38.586] GET http://www.facebook.com/plugins/likebox.php?href=https://www.facebook.com/pages/True-Secrets-Melbourne/173988669303957&width=180&colorscheme=light&show_faces=false&connections=1&stream=false&header=false&height=130 [HTTP/1.1 302 Found 951ms]
[02:36:38.621] GET http://www.tripadvisor.com.au/WidgetEmbed-linkingWidget?uniq=744&locationId=2306432&lang=en_AU [HTTP/1.1 200 OK 785ms]
[02:36:38.642] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/themes/one-more-night-10/images/sidebar-h2-bg.gif [HTTP/1.1 404 Not Found 1534ms]
[02:36:39.745] GET http://www.facebook.com/plugins/like.php?action=recommend&channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df5bf9df8ac72ee%26origin%3Dhttp%253A%252F%252Fwww.truesecrets.com.au%252Ff2312aa3a5ab046%26relation%3Dparent.parent%26transport%3Dpostmessage&extended_social_context=false&href=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&layout=button_count&locale=en_US&node_type=link&sdk=joey&send=false&show_faces=false&width=450 [HTTP/1.1 302 Found 569ms]
[02:36:40.008] GET http://platform.twitter.com/widgets/images/t.gif?_=1317623799367&count=horizontal&id=twitter_tweet_button_0&lang=en&original_referer=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&text=%40TrueSecretsMelb%20is%20an%20awesome%20experience%20in%20%23Melbourne%20Australia%20%23ThingsToDo&url=m.truesecrets.com.au&twttr_referrer=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&twttr_li=1&twttr_widget=1&twttr_guest_id=v1%3A131734641621996305 [HTTP/1.1 200 OK 712ms]
[02:36:40.032] GET http://cdn.api.twitter.com/1/urls/count.json?url=m.truesecrets.com.au&callback=twttr.receiveCount [HTTP/1.1 200 OK 765ms]
[02:36:40.080] GET https://plusone.google.com/u/0/_/+1/fastbutton?url=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&size=medium&count=true&annotation=&hl=en-GB&jsh=r%3Bgc%2F23980661-3686120e#id=I1_1317623799809&parent=http%3A%2F%2Fwww.truesecrets.com.au&rpctoken=783093808&_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe [HTTP/1.1 200 OK 1008ms]
[02:36:40.150] GET https://www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FTrue-Secrets-Melbourne%2F173988669303957&width=180&colorscheme=light&show_faces=false&connections=1&stream=false&header=false&height=130 [HTTP/1.1 200 OK 1526ms]
[02:36:40.237] GET https://www.facebook.com/plugins/like.php?action=recommend&channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df5bf9df8ac72ee%26origin%3Dhttp%253A%252F%252Fwww.truesecrets.com.au%252Ff2312aa3a5ab046%26relation%3Dparent.parent%26transport%3Dpostmessage&extended_social_context=false&href=http%3A%2F%2Fwww.truesecrets.com.au%2Fstrange-tours-melbourne%2F&layout=button_count&locale=en_US&node_type=link&sdk=joey&send=false&show_faces=false&width=450 [HTTP/1.1 200 OK 1748ms]

Open in new window

[02:38:00.917] GET http://m.truesecrets.com.au/strange-tours-melbourne/ [HTTP/1.1 200 OK 2966ms]
[02:38:03.646] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/themes/mobile_pack_base/groups//styles/reset.css [HTTP/1.1 404 Not Found 1972ms]
[02:38:03.655] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/themes/mobile_pack_base/groups//styles/baseStyles.css [HTTP/1.1 404 Not Found 2697ms]
[02:38:03.666] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/themes/mobile_pack_base/groups//scripts/templates.js [HTTP/1.1 404 Not Found 2818ms]
[02:38:06.530] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/formidable/css/frm_display.css?ver=1.05.05 [HTTP/1.1 304 Not Modified 753ms]
[02:38:06.541] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelementplayer.css?ver=3.2.1 [HTTP/1.1 304 Not Modified 784ms]
[02:38:06.555] GET http://m.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/l10n.js?ver=20101110 [HTTP/1.1 304 Not Modified 803ms]
[02:38:06.708] GET http://www.google-analytics.com/__utm.gif?utmwv=5.1.7&utms=3&utmn=1199503057&utmhn=m.truesecrets.com.au&utmcs=UTF-8&utmsr=1920x1080&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=11.0%20d1&utmdt=Strange%20things%20to%20do%20in%20Melbourne&utmhid=1500167866&utmr=-&utmp=%2Fstrange-tours-melbourne%2F&utmac=UA-25243711-1&utmcc=__utma%3D27771744.844043159.1317612041.1317619682.1317623485.3%3B%2B__utmz%3D27771744.1317623485.3.3.utmcsr%3Dexperts-exchange.com%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2FSoftware%2FServer_Software%2FWeb_Servers%2FMicrosoft_IIS%2FQ_27375877.html%3B&utmu=q~ [HTTP/1.1 200 OK 772ms]
[02:38:07.308] GET http://m.truesecrets.com.au/strange-tours-melbourne/wp-includes/js/jquery/jquery.js?ver=1.6.1 [HTTP/1.1 304 Not Modified 635ms]
[02:38:08.031] GET http://www.truesecrets.com.au/strange-tours-melbourne/wp-content/plugins/html5avmanager/lib/mediaelement/mediaelement-and-player.min.js?ver=3.2.1 [HTTP/1.1 304 Not Modified 512ms]
[02:38:08.584] GET http://m.truesecrets.com.au/strange-tours-melbourne/wp-admin/js/password-strength-meter.js?ver=20101027 [HTTP/1.1 304 Not Modified 363ms]

Open in new window

0
 
Craig LambieAuthor Commented:
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
0
 
David Johnson, CD, MVPOwnerCommented:
firefox 7 just about the same is available with ie9 (hit f12)
0
 
Craig LambieAuthor Commented:
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??
0
 
David Johnson, CD, MVPOwnerCommented:
in the www.* site create a binding www.sitename.com.au
then create a blank website binding sitename.com.au
go into the configuration editor under system.web.server/httpredirect
put the destination as the www.sitename.com.au
now you should get the 301 redirects

url rewrite should always give a 200 ok response
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now