redirect a single page?

Topics: User Forum
May 31, 2011 at 9:54 PM
Edited Jun 1, 2011 at 10:05 AM

Hi all

Is there a way to redirect a single page?  I'm simply trying to redirect sitemap.aspx to sitemap.xml

I've tried this but I'm rubbish :(

# make requests for /sitemap.xml redirect to sitemap.aspx for search engines expecting this path

RewriteCond %{HTTP_HOST} ^mydomain.com\sitemap.xml$ [I] 

RedirectRule ^/(.*) http://www.mydomain.com\sitemap.aspx/$1 [R=301]

 

Like shown here: http://www.eyecatch.no/blog/changing-file-type-extension-with-iis-7.aspx/

Any thoughts?

Lea

Jun 1, 2011 at 11:18 AM
Edited Jun 3, 2011 at 2:42 PM

Blimey - I think I've done it:

I chose the RewriteRule as there was no need to tell the browser we've actually served a different page.

RewriteRule ^/sitemap\.xml /sitemap.aspx

 

I have to say as a complete nuub I found it confusing when to add end of line terminations ($) and when not.

This example doesn't use any:

RewriteRule ^/cart /ViewCart.aspx

Where as this one does:

RewriteRule ^/sitemap\.xml$

 

Guessing this is because of my poor understanding of this GREAT tool - thanks Cheeso

Lea

 

Coordinator
Jun 2, 2011 at 2:23 PM

Lea, sounds like you have your solution.

 

Regarding end-of-line assertions, it depends on how you want to match.  A pattern like  ^/cart   will match a url with a query string, eg,

/cart?display=print

..while a pattern like    ^/cart$      will not match that URL, because it asserts that nothing can follow the t. 

In the examples you cite, I suppose that I wasn't trying to explicitly make a point of how to properly use $.   I was covering some other point, probably.

I don't understand why your sitemap.xml rule would fail to rewrite if it included a $.  If I had to guess, I'd say that perhaps to crawlers are requesting sitemap.xml?something - in other words, there's a query string appended.  The crawlers might do this to contrive a unique URL; appending a timestamp on a dummy-named query parameter is one common way to do this.

To illustrate, requesting "sitemap.xml" will get the sitemap.xml resource, but it might be a cached version, and could be out of date.  A request for "sitemap.xml?_=393893" is going to be a unique request, and it cannot be fulfilled from any cache, therefore it is more likely to be generated "fresh". 

I don't know if this is what is happening for you, just a guess. One way to find out is to check the IIRF log.  Another source of insight might be the IIS log that will show the incoming requests for sitemap.xml .

But if it already works for you, maybe there is nothing further you need to do. A question you don't need the answer to.

 

 

Jun 3, 2011 at 3:05 PM

Once again, thank you Chesio for the $ explanation and yes you were covering something completely different so perhaps I presented it somewhat out of context.

I'm not sure why the request fails when I add the $ if I'm honest and to test I'm simply calling it directly from a browser...however, everyone's time is limited and so it's working for me :) and yep, a questions for now that can be burried ;-)

BTW - I'm not sure if I have donated, so I'll certainly be doing so in the near future.

IIRF is brilliant for W2K3 use  - and your support is supperb too.

Lea

 

Coordinator
Jun 4, 2011 at 3:35 AM

Thanks Lea, glad you like IIRF.

This started as just an idea, a case where I wondered if I could produce a rewriter. Then someone asked for real support, and someone else asked for a few other features, and off to the races I went. I figured with IIS7 people would lose interest in IIRF, but no, there is still a ton of use.  Soon W2k3 will go out of support so I suppose interest in IIRF will wane.  But we had a good run!