Mod_rewrite to redirect to new subdomain?

Blogger is stopping ftp publishing, so we’re forced to move our news page from www.ourdomain.co.uk/news/news.html to news.ourdomain.co.uk

I’ve tried various attempts at doing this by creating RewriteRule’s but nothing seems to work.

Can anyone help please?

This rule doesn’t work:

RewriteRule www.mydomain.co.uk/news/news\.html$ http://news.mydomain.co.uk/ [R=301,L]

I suspect I need to use a RewriteCond but nothing I’ve found has pointed me in the right direction.

Actually, after wasting quite a while trying to solve this, I just remembered that rewrite rules don’t work if the old page still exists…

Yep, that was it.

RewriteRule ^news/news\.html$ http://news.mydomain.co.uk/ [R=301,L]

does actually work!

bb,

:eek2: You must use the DirectoryIndex of the subdomain?

RewriteRule www.mydomain.co.uk/news/news\\.html$ http://news.mydomain.co.uk/ [R=301,L]

Correct! That will NOT work because a RewriteRule can only examine the {REQUEST_URI} string, i.e., www.mydomain.co.uk will NOT be seen by the RewriteRule!

If this is in the same PHYSICAL directory, you’ll need to test the {HTTP_HOST}, too!

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www/.)mydomain\\.co\\.uk [NC]
RewriteRule ^news/news\\.html$ http://news.mydomain.co.uk/ [R=301,L]

Regards,

DK