views:

835

answers:

2

I'm moving my blog which was in a physical folder (/blog/) on my IIS 6 web server to a virtual directory called the same name (blog) running BlogEngine.net, the virtual directory is running in the same application pool as the parent website.

I want to redirect each .html post to the new BlogEngine.net URL. e.g.

http://www.mywebsite.co.uk/blog/2009/06/old-blog-title.html to http://www.mywebsite.co.uk/blog/post/new-blog-title.aspx

I already have Helicon ISAPI Rewrite Version 3.1.0.58 running on my website and currently have redirects working fine. But redirects to the blog virtual directory don't seem to work.

Current .htaccess rule:

#rewriterule ^blog/2009/06/old-blog-title.html$ /blog/post/new-blog-title.aspx [R=301,L]

Question 1: Should I add the .htaccess rules to the blog Virual Directory root or the main website root?

Question 2: What .htaccess syntax should I be using to redirect to the virtual directory?

Thanks in advance for your help.

+1  A: 

I didn't get any response, but managed to figure it out myself. Is there a StackOverflow badge for that LOL :-) I'm answering my own question just incase anyone else has the same problem.

Answer to Question 1

The .htaccess file should be located in the virtual directory root, but you can't edit this in the Helicon Rewrite tab of IIS 6 for the virtual directory as it wants to save the .htaccess file in a physical directory called /blog/ rather than the virtual directory.

Answer to Question 2

The rewrite needed to be amended slightly due to the .htaccess file location within the virtual directory. Basically removing blog/ from the beginning of the old url.

rewriterule ^2009/06/old-blog-title.html$ /blog/post/new-blog-title.aspx [R=301,L]
Absolut40
+1  A: 

Your rule is OK if you need to redirect just a couple of blog articles, but if you'll have hundreds of them, you'd better have a look at mapfiles functionality of ISAPI_Rewrite here.

but you can't edit this in the Helicon Rewrite tab of IIS 6 for the virtual directory

This problem was fixed in build 62, so update and enjoy.

TonyCool
Unfortunately the old URLs don't follow a consistent structure where I can apply a rule to them :-(Thanks for the heads-up on the Helicon Rewrite fix though!
Absolut40