Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

hopefully someone can give me a roadmap to get this done.

I run a self-hosted Wordpress blog at

http://www.example.com

which has numerous posts/links such as

http://www.example.com/videos/this-is-post-23/ http://www.example.com/pictures/this-is-post-34/ http://www.example.com/news/this-is-post-67/

I am now planning in moving to a new domain, http://mysite.com.

I would like to move my content into mysite.com as follows:

http://mysite.com/blog/videos/this-is-post-23/ http://mysite.com/blog/pictures/this-is-post-34/ http://mysite.com/blog/news/this-is-post-67/

My sense is that a 301 redirect will not suffice and wonder if changes elsewhere (htaccess?) are needed to make this move without screwing up my pagerank (currently 5).

Any ideas or suggestions? My server is LAMP.

Thanks for helping!

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

301 Redirect is exactly what you need. You new URL (on new site) has single & very small constant/persistent difference: new URL has /blog in front of old URL.

As simple as:

Redirect 301 / http://mysite.com/blog/

The same but using mod_rewrite:

RewriteEngine On

RewriteRule (.*) http://mysite.com/blog/$1 [R=301,L]

Any of these rules should be place in .htaccess in website root folder on www.example.com site and placed before WordPress rewrite block.

The "bad" thing -- is that requests for images and other static resources (on old site) are also will be redirected .. and if they are located in a different location (not in /blog folder), you may have quite a few 404 hits on your new site (that's if someone will be requesting those resources directly, which should not happen under normal circumstances).

share|improve this answer
    
thanks @lazyone, very helpful - so what you're saying is that if there's something like http://www.example.com/images/picture.jpg on someone else's site they will get a broken link? –  torr Aug 6 '11 at 15:04
    
@torr Yes. To prevent this you will have to place some other rules before these 301 redirects: to still serve them from old domain (in other words, only redirect articles and not real files) .. or just add few more specific 301 redirects, like Redirect 301 /images/ http://mysite.com/images/ -- but place them before article redirects). –  LazyOne Aug 6 '11 at 15:56
    
@torr But keep in mind -- once you stop sing old domain name completely (will expire/no longer belong to you) such link on someone else's site will become broken anyway, unless they will manually change the link (which is quite unlikely they will notice it quickly if at all). –  LazyOne Aug 6 '11 at 16:06
    
thx @ lazyone - re internal links in a post, do you know if Wordpress stores relative or full paths in the database? if not, i will have to manually change all of them... –  torr Aug 6 '11 at 18:12
    
@torr Sorry, I do not know. But even if links to your site are stored as full URL (including domain name), simple Find&Replace should do the job (and I think phpMyAdmin provides such functionality, although cannot guarantee 100%). In any case, if you will be exporting your DB to another server, you can open that backup file (if it is not compressed somehow) in text editor and do it there -- that's how I was dealing with Magento shopping cart in the past. –  LazyOne Aug 6 '11 at 18:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.