chris
chris

Reputation: 36957

htaccess redirect all traffic to non image files to another site, and redirect all image traffic to a single image

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?

Upvotes: 0

Views: 402

Answers (1)

Sean Johnson
Sean Johnson

Reputation: 5607

The following should work:

RewriteEngine on
RewriteRule \.(jpg|jpeg|png|gif)$ http://yournewsite.com/imagetoshow.png [NC,L,R]
RewriteRule (.*) http://yournewsite.com [R]

Upvotes: 4

Related Questions