PDA

View Full Version : Redirecting folder to subdomain - fairly urgent question


braiiins
08-02-2009, 07:57 PM
Working on a friend's site and need some help.

She set up a redirect for her WordPress from herdomain.com to wp.herdomain.com. Images from here on out in posts are setting themselves up fine when inserting them into posts, but images in all past posts won't redirect to wp.herdomain.com/wp-content/ as they are supposed to. I tried setting up redirects in .htaccess to redirect the whole folder from herdomain.com/wp-content/uploads/ to wp.herdomain.com/wp-content/ but it isn't working.

I'll be honest in saying I don't know much, if anything, about this stuff, so I honestly don't know if I'm doing it right, but I know it isn't working.

Now we could go into every post and change the img src manually, but there's over 1600 posts, so it would take days, and her new site launches tomorrow. There's also more than just images in the folder, and it's quite messy, so I'm not sure how she set everything up... I just want to make sure that everything redirects to the subdomain.

Is there anything I can put into .htaccess to alert the site that it's supposed to be loading through the subdomain now?

Thank you for any help in advance!

BlakeG
08-02-2009, 09:54 PM
It should work...

RewriteRule ^wp-content/uploads/(.*) http://wp.herdomain.com/wp-content/$1 [R=301,L]

BlakeG
08-02-2009, 10:01 PM
And... maybe you should add a rewrite condition just to make sure the wp.herdomain.com doesn't redirect more deeper.
So instead of the previous code, use this:

RewriteCond %{HTTP_HOST} ^(www\.)?herdomain\.com$
RewriteRule ^wp-content/uploads/(.*) http://wp.herdomain.com/wp-content/$1 [R=301,L]

I hope it helps.

braiiins
08-02-2009, 11:00 PM
Thank you so much for your help. Your code probably would have worked, but I thought of something. She also redirected her domain to another domain, which I think was causing the problem. She wanted anything not loaded under wp.herdomain.com to redirect to herdomain2.com, and I think it was interfering with your code. I found a plugin to search and replace the img srcs in all of the posts, so instead of spending days trying to do it manual, I was able to do it in seconds. (for anyone interested, the WP plugin is called Find and Replacer)

I'm very thankful that you replied, though! I'm new here, and still got a reply on my first post, while at the WP forums, no one ever helps! So, thank you again.

BlakeG
08-02-2009, 11:11 PM
No problem, braiiins... ;)