Image requests pointing to subdomain

  • BIOSTALL
  • Graduate
  • Graduate
  • User avatar
  • Posts: 125
  • Loc: UK

Post 3+ Months Ago

Hi all,

I am currently optimising my site so it loads quicker and one of the things I am looking at doing is hosting all media on http://media.mysite.com.

The question I have is; do I have to go through my entire site and change all img tags to the new subdomain or is there something I can do in .htaccess to achieve this?

The only reason i ask is I have thousands of pages on my site and it would take quite a while to go through them all.

Thanks in advance
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Optimally, you want to change your pages. There are ways to redirect those image requests in htaccess, but the server is still going to have to process each of the requests in order to redirect them, which partially defeats the purpose of making the switch in the first place.

What I would do is use sed/perl/php/etc to rewrite all of the <img> tags to the new domain from the terminal. That should take care of a large portion of the work all at once if care is taken when crafting the script that does the file editing.

Once that was done I would monitor the request logs for the next few days looking for image URLs. Then I'd grep the filesystem looking for those URLs and work out a way to edit them en-mass programmatically as well.
  • BIOSTALL
  • Graduate
  • Graduate
  • User avatar
  • Posts: 125
  • Loc: UK

Post 3+ Months Ago

Thanks joebert, thats excellent. I've ran a mass Find/Replace on the site and will keep an eye on the logs.

BIOSTALL

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.