0

I've got a wordpress blog on a subdirectory which I've recently migrated from a .com to a .co.uk (myurlstudio.com/blog to myurl.co.uk/blog). The problem is that many of the posts have images in them, and their hrefs still point to the old domain, and so they don't work with the current htaccess settings. The images point to http://www.myurlstudio.com/blog/wp-content/uploads/image.jpg, when I want them to point to http://www.myurl.co.uk/blog/wp-content/uploads/image.jpg. So the thing I need to change in htaccess is 'http://www.myurlstudio.com/blog' to 'http://www.myurl.co.uk/blog' wherever it comes up.

Current htaccess looks like this (it's the standard URL-rewriting scheme for concrete5):

# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?myurlstudio.com$
RewriteRule ^(.*)$ http://www.myurl.co.uk/$1 [L]


RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]


</IfModule>
# -- concrete5 urls end --

As you can see myurlstudio.com is redirected, but URLs inside documents don't seem to be rewritten.

Any help would be much appreciated!

3
  • 1
    mod_rewrite doesn't change the contents of your HTML, javascript, and CSS resources. It modifies the request being processed, not the content being served. You'll want to look into fixing the links in your content. Nov 16, 2011 at 15:59
  • Do www.myurlstudio.com and www.myurlstudio.co.uk resolve to the same host? So, is the above htaccess file for both of those hosts, or for just one of them, and if so which? Nov 16, 2011 at 16:00
  • @Andrew - yes they do. myurlstudio.com is parked on top of myurl.co.uk (it wasn't when the blog was first created, but now it is).
    – melat0nin
    Nov 16, 2011 at 16:07

1 Answer 1

1

If you have access to the old host (sounds like you do from the comments), your rule should work when placed in the docroot of the old site:

RewriteCond %{HTTP_HOST} ^(www.)?myurlstudio.com$
RewriteRule ^(.*)$ http://www.myurl.co.uk/$1 [L,R=301,QSA]

BUT that only redirects old requests. You still need to update the site to reference the new domain if the old domain is to expire eventually.

1
  • Unfortunately that doesn't change requests in the HTML. I suspect it's not actually possible :(
    – melat0nin
    Jan 4, 2012 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .