views:

113

answers:

2

I am moving a blog from one server to another and adding a subdomain, so the path will change from -

http://www.example.com/queen/index.php/2009/winners-and-losers/

to -

http://blogs.example.com/queen/2009/winners-and-losers/

What mod_rewrite rules would I add to the .htaccess under /queen/ on www.example.com to 301 redirect to the new http://blogs.example.com/queen/?

What is changing is the 'www' > 'blogs' and the 'index.php/' is going away.

Thanks!

A: 

Off the top of my head:

RewriteRule ^./index.php(.)$ http://blog.foo.com/queen$1 [R=301]

timdev
+1  A: 

Try this rule:

RewriteRule ^index\.php/(.*) http://blogs.example.com/queen/$1 [L,R=301]

And if that folder is also accessible through other host names but the rule should only be applied within www.example.com:

RewriteCond %{HTTP_HOST} =www.example.com
RewriteRule ^index\.php/(.*) http://blogs.example.com/queen/$1 [L,R=301]
Gumbo
I get a 404 when I try that. The old .htaccess used to look like this-RewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^([^/]+/[^/]+/?)$ index.php/$1 [NC,L]I renamed the sub-folder it was in and created a new /queen/ folder that is empty except for the .htaccess file that now has-RewriteBase /RewriteRule ^index\.php/(.*) http://blogs.theroanoker.com/queen/$1 [L,R=301]But my URLs generate a 404. Did I do something wrong?
Marty
@Marty: Don’t use `RewriteBase` if you don’t need to alter the base URL path.
Gumbo