Forum Moderators: phranque
Does your code need to work for both non-www and www? Does it need to retain the same part-parts in the old and new URL? Do any of the URLs have parameters? How do they need to be treated?
Let's see you best effort code and we'll take it from there...
It is possible, for example, to use a URL of example.com/abc, but have the server get the contents from /blog/abc
It is also possible to use a URL of blog.example.com/xyz and have the server supply content stored in /blog/xyz
Everything depends on what URLs you want to use, and on how/where your install WP.
Jim
<edit>Ah, a response while I was reading other posts. But now www.example.com is quoted instead of example.com - note the devil really is in the details.</edit>
My blog is located in www.example.com, I want to move it to [mydomain.com...] I have already moved the wordpress files and copy of database so the blog can be acccess from both urls, now I just need to do 301 redirect :) I hope this clears the air
# Canonicalise mydomain.com
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [OR]
RewriteCond %{HTTP_HOST} ^mydomain\.com(\.¦:[0-9]+¦\.:[0-9]+)$
RewriteRule (.*) http://mydomain.com/$1 [R=301,L]
#
# Redirect www and example.com to mydomain.com/blog
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule (.*) http://mydomain.com/blog/$1 [R=301,L]