Take the 2-minute tour ×

I have a handful of sites I am taking down for a while due to a recent hosting company move, and my primary focus being shifted towards a large project else where, that will ultimately leave my sites down and out for awhile.

So what I need to at the least do is drop an htaccess file in all the domains in question and have all non image based traffic point towards a domain that will actually be up and running, a redirect 301 or whatever, and then have a similar logic applied to just images so I can have images being hosted elsewhere like old form posts point to a single image again on the same domain that will be up.

I need to do this because my server error logs are filling up 10k+ lines an hour due to all the 404 and file not found issues from the other domains. Actually Ideally I would like to point all traffic to one lone file, and then use that file to dump the errors in a database, but use that same file to serve a single image in the event that it was an image request.

Are either of these to logics possible?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The following should work:

RewriteEngine on
RewriteRule \.(jpg|jpeg|png|gif)$ http://yournewsite.com/imagetoshow.png [NC,L,R]
RewriteRule (.*) http://yournewsite.com [R]
share|improve this answer
really? thats it? I thought it'd be a bit more than that, but hey if it works. Im not gonna complain, thank you –  chris Jun 24 '12 at 23:40
At least if I understood your explanation correctly. If you plan on hosting the images on a seperate domain, I'll have to modify the first RewriteRule to actually capture the name of the image the client is trying to request and write the redirect URL accordingly. As it stands, all images are directed to a single image, and all other traffic is redirected to yournewsite.com. –  Sean Johnson Jun 24 '12 at 23:44
Eventually I intend to have all the old images on one master domain, and having a one to one redirect based on the capture of that filename would be awesome. For the current time though I am just going to serve up a single image file as there replacements til I get around to adding the images to a specific domain. My end run goal for the one to one is catch the name, server a php file with the header matching that of the filename type that is caught, and using the php file to output accordingly for the matches. –  chris Jun 25 '12 at 1:05
Alright, then my answer should be exactly what you want for now. You know where to come for help should you need it when you get around to making the one-to-one matching. :) –  Sean Johnson Jun 25 '12 at 1:07
Right now I am just trying to kill the massive heap building up in my error logs every day cause I have the domains setup on the server, but to get the sites running again, even with the imagery is going to be a massive undertaking one of which I dont have time for currently due to a project I am working on. Curious would it be possible in the rewrite rule that points all traffic thats not images to a main domain to pass the file/domain it was trying to access as a variable in a matter of speaking along with redirecting to the new domain –  chris Jun 25 '12 at 1:10

Your Answer


