I have a single site within IIS, which runs on 4 different hostnames. The CMS handles that, and displays the correct site based on the incoming hostname.
I need to use ISAPI rewrite to handle all the old urls and 301 redirect them to the new equivalants, this is how I currently deal with redirects in my ISAPI-rewrite .htaccess file
RewriteEngine on
RewriteRule ^post/my-old-page-one$ /my-newer-page-one [R=301]
RewriteRule ^post/my-old-page-two$ /my-newer-page-two [R=301]
My issue is, I need it to check the domain too for the incoming url. As the sites have the same old urls, which now need to go to a different page.
I was hoping I could so this.
RewriteEngine on
RewriteRule ^http://www.siteone.com/post/my-old-page-one$ http://www.siteone.com/my-newer-page-one [R=301]
RewriteRule ^http://www.siteone.com/post/my-old-page-two$ http://www.siteone.com/my-newer-page-two [R=301]
RewriteRule ^http://www.sitetwo.com/post/my-old-page-one$ http://www.sitetwo.com/my-newer-page-one [R=301]
RewriteRule ^http://www.sitetwo.com/post/my-old-page-two$ http://www.sitetwo.com/my-newer-page-two [R=301]
But it doesn't work. Any advice greatly appreciated.
The check of the hostname is performed in a separate condition, like this:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.siteone\.com$ [NC]
RewriteRule ^post/my-old-page-one$ http://www.siteone.com/my-newer-page-one [R=301,NC,L]
RewriteCond %{HTTP_HOST} ^www\.siteone\.com$ [NC]
RewriteRule ^post/my-old-page-two$ http://www.siteone.com/my-newer-page-two [R=301,NC,L]
RewriteCond %{HTTP_HOST} ^www\.sitetwo\.com$ [NC]
RewriteRule ^post/my-old-page-one$ http://www.sitetwo.com/my-newer-page-one [R=301,NC,L]
RewriteCond %{HTTP_HOST} ^www\.sitetwo\.com$ [NC]
RewriteRule ^post/my-old-page-two$ http://www.sitetwo.com/my-newer-page-two [R=301,NC,L]